Hi, all I'm trying to do is have my program request a name then after name is inputted, ask if there are any more names to add [Y/N].
Problem is program keeps displaying 'add name' and 'any more names to add' on the same line without giving the option to add a name only to input Y/N! Yes, I'm a newbie... it figures...
Have spent hours tweaking these few lines of code and am now at my wits end. Any suggestions would be greatly appreciated.
int f_enter_name ()
{
/* local variables */
char reply;
float count = 0;
int num_of_friends = 0;
do
{
printf ( "Please enter the name to add to record %d > ", num_of_friends + 1 );
gets ( friend_info[num_of_friends].name );
fflush (0);
do
{
printf ( "Are there any more names to add? Y/N > " );
scanf ( "%c", &reply );
fflush (0);
if (( reply != 'Y' ) && ( reply != 'y' ) && ( reply != 'N' ) && ( reply != 'n' ))
{
printf ( "Error. Y or N only\n" );
}
}
while (( reply != 'Y' ) && ( reply != 'y' ) && ( reply != 'N' ) && ( reply != 'n' ));
num_of_friends ++;
count = count + 1;
}
while (( reply == 'Y' ) || ( reply == 'y' ) && ( num_of_friends < 20 ));
return ( count );
}
Thanks for looking!