Quit when user enter "STOP"

cnoobprogrammer's Avatar, Join Date: Mar 2012
Newbie Member

I am a novice in C Programming. And I have some problem regarding to using while or do while loop to quit when user enter "STOP". I have a case statement which will execute this. And I wanted to quit user input when "done" is entered by the user.

The following is my code:

case 2:
printf("Enter name and their id");
while (strcmp(name,"stop")!=0)
scanf("%s %d",name,&id);
/*create customer record function here so after every scan, i will pass in the parameters name and id*/

I will appreciate any help and thank you!
dearvivekkumar's Avatar, Join Date: Feb 2012
Go4Expert Member
char name[100] = {'\0'};
int id = -1;
    printf("Enter name -> ");
    scanf("%s", &name);
    printf("Enter id - > ");
    scanf("%d", &id);
}while(strcmp(name, "stop") == 0);