how can you transfer contents of a 1D array into a 2D array as in; if the sentence "i am a good boy" is stored in a 1D array text[50] then it should be transferred into a 2D array text2[50][50]={"i","am","a","good","boy"}
i have written the following code but it isnt working..... plz suggest somethin....
#include<stdio.h>
#include<conio.h>
main()
{
char text[50],text2[50][50];int i=0,j=0,k=0;
printf("enter a text ");//to enter the contents of the 1D array text
gets(text);
while(text[i]!='\0')//to put the contents into the 2D array
{ if(text[i]==' ')
{
j++;k=0;
}
else
{
text2[j][k]=text[i];
}
i++;
}
j=0;k=0;
while(text2[j][k]!='\0')//to print the contents of the 2D array
{
while(text2[j][k]!='\0')
{
printf("%c",text2[j][k]);
k++;
}
j++;k=0;
}
getch();
}