I can't figure out what is wrong with this program. I have tried using
strncpy(text,array[ ],sizeof(text))
already but that didn't solve anything. What I need is a simple method of copying string like in pascal language, where a simple equal sign can be used to copy string (or a generated function that can do this). this is the source code:
#include <stdio.h>
#include <string.h>
int x,y;
char array[10][10];
int choice;
char text[5];
int main()
{
for(x=0;x<5;x++)
{
printf("ENTER text: ");
scanf("%s", text);
strcpy (text,array[x]);
}
for (y=0;y<5;y++)
{
printf("\n");
printf("%s", array[y]);
}
return 0;
}
the output should be something like;
"*string*"
"*string*"
"*string*"
"*string*"
"*string*"
but all i get is five spaces, no string. Any Solutions?