user account name input

Aigolek's Avatar, Join Date: Apr 2010
Newbie Member
Hi, everybody! I want to ask one question, i have piece of code where i am trying to validate user account name input, and it seems working, despite of one thing if I put non existing name, the programs continue work, however it should be terminated. The code of problem is here:
Code:
printf("\nEnter Account Name: ");
    fflush(stdin);
    fgets(name, sizeof(name), stdin);        
    int len = strlen(name);
    if(name[len-1] == '\n')        
    name[len-1] = '\0'; 
    while (fread(buffer, sizeof(account), 1, members))
	{ 
		if(strcmp(buffer->acc_name, name)==0){
               fgetpos(members,&here);
               printf ("\nAccept! Account exists.");
               break;
               fsetpos(members, &here);
        } 
        else{
              if (!feof(members))continue;
              else 
             {
               break; printf("Account does not exist");
               exit(1);}
              } 
 
	}
when i debugging the code with non exisistng account name, it missing this part,
Code:
else 
             {
               break; printf("Account does not exist");
               exit(1);}
              }
And i really cannot understand why it doesn't go there.I've tried to change the loop structure, but it doesn't work. I really cannot get what it can be. Thank you very much for help
0
virxen's Avatar, Join Date: Nov 2009
Pro contributor
remove the break;