How can I copy a string (array of character) to an array of string such as:
char text[a][b];
wherein a is the index number of the array and b is the max length of array of characters that can be stored in the array..
For example I have an array of characters "char word[20];"
How can I store it to an array of strings "char text[99][20];"??
Please help.. And thanks..
Can you help me a problem in arrays of strings in C?
you can use the strcpy() function.
strcpy(text[99], word);
or:
for (int a = 0; a %26lt; 20; a++)
{
text[99][a] = word[a];
}
both will work.
Reply:Yes it is possible!!
Wat U need to do is that for example
let
char word[5]={'a','b','c','d','e'};
char test[20][10];
for(i=0;i%26lt;5;i++)
{ {test[p][q]=word[i];
q++;}
if(q==10)p++;
}
Ok Gud LC Bye
Reply:for (int x=0; x%26lt;20; x++)
{
text[0][x] = word[x];
}
// This will copy the char array word into the first row in text.
// word is a one dimensional array.
// text is a two dimensional one.
magnolia
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment