3 Replies - 829 Views - Last Post: 04 September 2009 - 10:41 PM Rate Topic: -----

#1 hd_pulse  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 31-August 09

add string in 2D array?

Posted 04 September 2009 - 11:36 AM

hello,

how to add string in 2-D array? Here I've thought of a code but this works sometimes and sometimes it don't work....

char a[M];
gets(a);
char k[A][A],r=0,c=0,i,j;
for(i=0;i<strlen(a);i++)
{
if(a[i]!=' ')
{
k[r][c]=a[i];
c++;
}
else
{
k[r][c]='\0';
r++;
c=0;
}
}



is the above mentioned code alright or I need to make some changes????
help!!!
thanks

This post has been edited by hd_pulse: 04 September 2009 - 11:53 AM


Is This A Good Question/Topic? 0
  • +

Replies To: add string in 2D array?

#2 Guest_Neumann*


Reputation:

Re: add string in 2D array?

Posted 04 September 2009 - 11:38 AM

Is there a good reason you're storing characters inside an array of integers?
Was This Post Helpful? 0

#3 hd_pulse  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 31-August 09

Re: add string in 2D array?

Posted 04 September 2009 - 11:56 AM

i've corrected the error now tell what could be done to store in 2D array
Was This Post Helpful? 0
  • +
  • -

#4 hd_pulse  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 31-August 09

Re: add string in 2D array?

Posted 04 September 2009 - 10:41 PM

View PostNeumann, on 4 Sep, 2009 - 10:38 AM, said:

Is there a good reason you're storing characters inside an array of integers?



After making the changes you suggested still the string in 2D array does not often works
????????????????????


PLZ HELP
thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1