Code:
#include <stdio.h>
#include <string.h>
int main ( void )
{
char studnam[20];
for ( ;; )
{
printf("Please enter the first and last name of the student: ");
fflush(stdout);
if ( fgets(studnam, sizeof studnam, stdin) )
{
char *newline = studnam + (strlen(studnam) - 1);
if ( *newline == '\n' )
{
*newline = '\0';
}
if ( strcmp(studnam, "bye") == 0 )
{
break;
}
printf("Please enter test scores of the student %s.\n", studnam);
/* ... */
}
}
return 0;
}
/* my output
Please enter the first and last name of the student: Dave Sinkula
Please enter test scores of the student Dave Sinkula.
Please enter the first and last name of the student: bye
*/