this is my problem... I created an array of strings like this..
char *name[12];
Then the user types 12 different names so I can save them in that array. But it is known that if you don't initialize a variable it has 'garbage' in it. So I started saving the names correctly until the 5th name, then it crashes, I don't know why. So I tried to initialize every element but then it doesn't allow me to change the content.
This is how I write into every element of the array:
printf("Type your name: ");
fflush(stdin);
gets( name[0] ); //I use a for to move into every element
And I want to know if there's any way to initialize the array, and to change it's content after that. I've tried with strcpy(); but I had the same error. Or how to delete that 'garbage' to stop it from causing me errors.
Thanks, and sorry if I had any misspelling. English is not my native language.
gets(). Andfflush(stdin)is undefined behaviour.malloc()to initialize them.