[Solved] I can not input the names into the char array using scanf


By

char *stdnames[100];

you got an array of (pointers to char).

The NEXT BIG QUESTION is

Who will allocate memory for each of these pointers?

A small answer would be – You have to do it yourself like below :

stdnames[count]=malloc(100*sizeof(char)); // You may replace 100 with desired size

or

stdnames[count]=malloc(100); // sizeof(char) is almost always 1

You need to put this line before the scanf statement.

Note: Don’t forget to free the allocated memory once these variables become irrelevant. Do it like :

free(stdnames[count]);

18

solved I can not input the names into the char array using scanf