I built a function that gets a string input from the user. Then it allocates memory, but after 3 inputs the program crashes.
void friendNamesInput(int friendNum, char **ppFriendName) {
char name[50] = { 0 }; //name
char *byteReALL = 0; //allocate bytes
int i = 0;
for (i = 0; i < friendNum; i++)
{
printf("Enter name of friend %d:", i + 1);
fgets(name, 50, stdin); //input 50
byteReALL = (char*)malloc(sizeof(char)*strlen(name)); //allcate nedded mem
strncpy(byteReALL, name,50); //copy string data
ppFriendName[i] = byteReALL; //address to array of arrays
}
}