EDIT: sorry, it's in C not C++, I get them mixed up sometimes. I changed lengthN == NULL
to lengthN == 0
and I'm getting an infinite loop after I enter the first name (if the name is longer than 15 characters).
So I am trying to make this thing that enters player names for this game I have to make for an assignment, and for some reason it doesn't repeatedly go through the loop. The loop SHOULD check the string length and if it is set to NULL
which would be outside the buffer, it will ask the user to re input, and will repeat itself until the correct length is input.
printf_s("Enter player %d's name (Max 15 characters): ", count);
scanf_s("%s", &name, 15);
lengthN = strlen(name);
printf_s("\n%s\n%d", name,lengthN);
while (lengthN == NULL)
{
printf_s("\nName too big; please enter a name within 15
characters!\n\n");
scanf_s("Enter name: %s", &name, 15);
lengthN = strlen(name);
}