I'm Trying to take names from the user in loop the user will enter how many names will be entered but the problem is when I use gets func in a loop every time it passes the very first gets in the loop lets say the user will enter 5 names because of this bug it can enter 4 names but enter the 1.name will shown on the screen too actually its not passing its taking it a space like ı didnt even entered first one its act like I just pressed enter and left it empty. here is the code;
for (int k = 0; k < namecounter; k++) {
printf("\nEnter the %d.Name :", k + 1);
gets(name_entry);
names[k] = (char*)malloc(strlen(name_entry) + 1);
if (names[k] == NULL) {
printf("insufficient memory!..\n");
exit(EXIT_FAILURE);
}
strcpy(names[k], name_entry);
}