C while loops tutorial example explained
#C #while #loop
int main()
{
// while loop = repeats a section of code possibly unlimited times.
// WHILE some condition remains true
// a while loop might not execute at all
char name[25];
printf("\nWhat's your name?: ");
fgets(name, 25, stdin);
name[strlen(name) - 1] = '\0';
while(strlen(name) == 0)
{
printf("\nYou did not enter your name");
printf("\nWhat's your name?: ");
fgets(name, 25, stdin);
name[strlen(name) - 1] = '\0';
}
printf("Hello %s", name);
return 0;
}
![](https://i.ytimg.com/vi/ufFAFx5Qn3w/maxresdefault.jpg)