Thread: Help me debug some part in my program

  1. #1
    Registered User
    Join Date
    Jan 2021
    Posts
    5

    Question Help me debug some part in my program

    hello, this coding works and run perfectly. just there are some minor mistakes while searching for the contact. the program will keep on print CONTACT RECORD IS NOT FOUND multiple times until the contact list arrangement is same to the list. Can someone show me the better coding for that part so that the contact will directly appear for the name searched without having to see the contact is not found. Please!


    Code:
    #include<stdio.h>
    //#include<conio.h>
    #include<string.h>
    #include<stdlib.h>
    //#include<windows.h>
    
    
    struct person
    {
        char name[50];
        char address[50];
        char father_name[35];
        char mother_name[30];
        long int mble_no;
        char sex[8];
        char mail[100];
        char ic_no[20];
    
    
        };
    void menu();
    void got();
    void start();
    void back();
    void addrecord();
    void listrecord();
    void editrecord();
    void deleterecord();
    void searchrecord();
    int main()
    {
        system("color 2f");
        start();
        return 0;
    }
    void back()
    {
        start();
    }
    void start()
    {
        menu();
    }
    void menu()
    {
        system("cls");
    printf("\n\n\t=========================================\n");
    printf("\t**********WELCOME TO PHONEBOOK***********\n");
    printf("\t=========================================\n");
    printf("\n\n\tMAIN MENU\t\t\n");
    printf("\n\t1. Add New Contact \n\n\t2. List All Contacts \n\n\t3. Edit Existing Contact \n\n\t4. Search Contact \n\n\t5. Delete Contact \n\n\t6. Exit \n\n\n\n\tENTER NO OF CHOICE : ");
    
    
    switch(getch())
    {
        case '1': addrecord();
        break;
       case '2': listrecord();
        break;
        case '3': editrecord();
        break;
        case '4': searchrecord();
        break;
        case '5': deleterecord();
        break;
        case '6': exit(0);
        break;
        default:
                    system("cls");
                    printf("\n\n\n\tERROR: ENTER NO 1 TO 6 ONLY!");
                    printf("\n\n\tEnter any key to return to main menu. ");
                    getch();
    
    
    menu();
    }
    }
            void addrecord()
    {
            char another='Y';
            system("cls");
            FILE *f;
            struct person p;
            while((another=='Y')||(another=='y')){
            system("cls");
            f=fopen("project","ab+");
            printf("\n\t===========================\n");
            printf("\t******ADD NEW CONTACT******");
            printf("\n\t===========================\n");
            printf("\n\n\tEnter name : ");
            got(p.name);
            printf("\n\n\tEnter home address: ");
            got(p.address);
            printf("\n\n\tEnter father's name: ");
            got(p.father_name);
            printf("\n\n\tEnter mother's name : ");
            got(p.mother_name);
            printf("\n\n\tEnter phone no (+60) : ");
            scanf("%ld",&p.mble_no);
            printf("\n\tEnter gender : ");
            got(p.sex);
            printf("\n\n\tEnter e-mail address : ");
             got(p.mail);
            printf("\n\n\tEnter IC No : ");
            got(p.ic_no);
            fwrite(&p,sizeof(p),1,f);
    
    
          fflush(stdin);
            printf("\n\n\n\tCONTACT HAS BEEN SUCCESFULLY ADDED!");
            printf("\n\n\tWant to add Another Contact? ( Y : Yes / N : No ) ---> ");
    fflush(stdin);
    another=getche();
     }
     if(another!='Y'||(another!='y')){
    fclose(f);
        system("cls");
        menu();
    }
    }
    
    
    void listrecord(FILE *f){
    int count=0;
    char keyPress;
    struct person p;
    f=fopen("project","rb");
    system("cls");
    printf("\n\t=============================\n");
    printf("\t******ALL CONTACT LIST******");
    printf("\n\t=============================\n");
    while(fread(&p,sizeof(p),1,f)==1){
    count++;
    
    
    printf("\n\n\n\tName = %s\n\n\tAdress = %s\n\n\tFather's name = %s\n\n\tMother's name = %s\n\n\tPhone no (+60) = %ld\n\n\tGender = %s\n\n\tE-mail = %s\n\n\tIC No = %s",p.name,p.address,p.father_name,p.mother_name,p.mble_no,p.sex,p.mail,p.ic_no);
    printf("\n\n\t-------------------------------------------------------------------");
    }
    if(count==0){
    printf("\n\n\n\tLIST STILL EMPTY. NOTHING TO DISPLAY!");
    }
    
    
    fclose(f);
        printf("\n\n\n\t- END OF LIST -\n");
        printf("\n\tEnter any key to return to main menu. ");
    
    
    	 getch();
        system("cls");
        menu();
    }
    
    
    void searchrecord()
    {
    
    
        int count=0;
    
    
        struct person p;
    
    
    FILE *f;
    char name[100];
    f=fopen("project","rb");
    if(f==NULL)
    {
        printf("\n\n\n\tERROR IN SEARCHING!\a\a\a\a");
    }
    system("cls");
    printf("\n\t===========================");
    printf("\n\t******SEARCH CONTACT******");
    printf("\n\t===========================\n");
    printf("\n\n\tENTER CONTACT NAME TO SEARCH : ");
    scanf("%s",&name);
    while(fread(&p,sizeof(p),1,f)==1){
    if(strcmp(strupr(p.name),strupr(name))==0){
        count++;
        system("cls");
            printf("\n\n\n\tDetail Information About: %s",name);
            printf("\n\n\tName : %s\n\n\tAddress : %s\n\n\tFather's Name : %s\n\n\tMother's Name : %s\n\n\tMobile No (+60) : %ld\n\n\tGender : s\n\n\tE-mail : %s\n\n\tIC No:%s",p.name,p.address,p.father_name,p.mother_name,p.mble_no,p.sex,p.mail,p.ic_no);
    }
        else
        printf("\n\n\tERROR: CONTACT FOR NAME %s IS NOT FOUND!",name);
    }
    fclose(f);
    printf("\n\n\tEnter any key to return to main menu. ");
    
    
    	 getch();
        system("cls");
    menu();
    }
    
    
    void deleterecord()
    {
        struct person p;
        FILE *f,*ft;
    	int flag;
    	char name[100];
    	f=fopen("project","rb");
    	if(f==NULL)
    		{
    
    
    			printf("\n\n\tCONTACT'S DATA NOT ADDED YET.");
    
    
    		}
    	else
    	{
    		ft=fopen("temp","wb+");
    		if(ft==NULL)
    
    
                printf("\n\n\tNO CONTACT RECORD TO DELETE!");
    		else
    
    
            {
            system("cls");
            printf("\n\t===========================");
            printf("\n\t******DELETE CONTACT******");
            printf("\n\t===========================\n");
    		printf("\n\n\tENTER CONTACT NAME TO DELETE : ");
    		got(name);
    
    
    		fflush(stdin);
    		while(fread(&p,sizeof(p),1,f)==1)
    		{
    			if(strcmp(p.name,name)!=0)
    				fwrite(&p,sizeof(p),1,ft);
    			if(strcmp(p.name,name)==0)
                    flag=1;
    		}
    	fclose(f);
    	fclose(ft);
    	if(flag!=1)
    	{
    		printf("\n\n\tCONTACT NOT FOUND!");
    		remove("temp");
    	}
    		else
    		{
    			remove("project");
    			rename("temp","project");
    			printf("\n\n\n\n\tCONTACT'S RECORD SUCCESSFULLY DELETED.");
    
    
    		}
    	}
    }
     printf("\n\n\tEnter any key to return to main menu. ");
    
    
    	 getch();
        system("cls");
    menu();
    }
    
    
    void editrecord()
    {
        char another='Y';
        int c;
        FILE *f;
        int flag=0;
        struct person p,s;
        while((another=='Y')||(another=='y')){
        system("cls");
    	char  name[50];
    	f=fopen("project","rb+");
    	if(f==NULL)
    		{
    
    
    			printf("\n\n\tCONTACT'S DATA NOT ADDED YET.");
    		}
    	else
    	{
    	    system("cls");
    		printf("\n\n\tENTER CONTACT NAME TO EDIT : ");
                got(name);
                while(fread(&p,sizeof(p),1,f)==1)
                {
                    if(strcmp(name,p.name)==0)
                    {
    
    
                        printf("\n\n\n\t=================================");
                        printf("\n\t******EDIT EXISTING CONTACT******");
                        printf("\n\t=================================\n");
                        printf("\n\tEnter name: ");
                        got(s.name);
                        printf("\n\n\tEnter address: ");
                        got(s.address);
                        printf("\n\n\tEnter father name: ");
                        got(s.father_name);
                        printf("\n\n\tEnter mother name: ");
                        got(s.mother_name);
                        printf("\n\n\tEnter phone no (+60) : ");
                        scanf("%ld",&s.mble_no);
                        printf("\n\tEnter sex: ");
                        got(s.sex);
                        printf("\n\n\tEnter e-mail: ");
                        got(s.mail);
                        printf("\n\n\tEnter IC no : ");
                        got(s.ic_no);
                        fseek(f,-sizeof(p),SEEK_CUR);
                        fwrite(&s,sizeof(p),1,f);
                        flag=1;
                        break;
    
    
    
    
    
    
                    }
                    fflush(stdin);
    
    
    
    
                }
                if(flag==1)
                {
                    printf("\n\n\n\tCONTACT RECORD SUCCESSFULLY MODIFIED!");
    
    
                }
                else
                {
                        printf("\n\n\n\tCONTACT FOR THE NAME: %s IS NOT FOUND!",name);
    
    
                }
                fclose(f);
    	}
    	 printf("\n\n\tEnter any key to return to main menu. ");
    	 getch();
        system("cls");
    	menu();
        }
    }
    void got(char *name)
    {
    
    
       int i=0,j;
        char c,ch;
        do
        {
            c=getch();
                    if(c!=8&&c!=13)
                    {
                        *(name+i)=c;
                            putch(c);
                            i++;
                    }
                    if(c==8)
                    {
                        if(i>0)
                        {
                            i--;
                        }
                       // printf("h");
                        system("cls");
                        for(j=0;j<i;j++)
                        {
                            ch=*(name+j);
                            putch(ch);
    
    
                        }
    
    
                    }
        }while(c!=13);
          *(name+i)='\0';
    
    
    }
    Last edited by tomatogrower; 01-23-2021 at 02:24 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Well the nicely formatted code here has been turned back into dog food.

    > the program will keep on print CONTACT RECORD IS NOT FOUND multiple times until the contact list arrangement is same to the list.
    Because you can't tell from your CRAP indentation that the print is INSIDE the loop.

    Code:
      while (fread(&p, sizeof(p), 1, f) == 1) {
        if (strcmp(strupr(p.name), strupr(name)) == 0) {
          count++;
          system("cls");
          printf("\n\n\n\tDetail Information About: %s", name);
          printf
              ("\n\n\tName : %s\n\n\tAddress : %s\n\n\tFather's Name : %s\n\n\tMother's Name : %s\n\n\tMobile No (+60) : %ld\n\n\tGender : s\n\n\tE-mail : %s\n\n\tIC No:%s",
               p.name, p.address, p.father_name, p.mother_name, p.mble_no, p.sex, p.mail, p.ic_no);
        } else
          //!! yes Dorothy, this happens on every node that doesn't match
          printf("\n\n\tERROR: CONTACT FOR NAME %s IS NOT FOUND!", name);
      }
    It should be outside the loop, maybe like
    Code:
      while (fread(&p, sizeof(p), 1, f) == 1) {
        if (strcmp(strupr(p.name), strupr(name)) == 0) {
          count++;
          system("cls");
          printf("\n\n\n\tDetail Information About: %s", name);
          printf
              ("\n\n\tName : %s\n\n\tAddress : %s\n\n\tFather's Name : %s\n\n\tMother's Name : %s\n\n\tMobile No (+60) : %ld\n\n\tGender : s\n\n\tE-mail : %s\n\n\tIC No:%s",
               p.name, p.address, p.father_name, p.mother_name, p.mble_no, p.sex, p.mail, p.ic_no);
        }
      }
      if ( count == 0 ) {
          printf("\n\n\tERROR: CONTACT FOR NAME %s IS NOT FOUND!", name);
      }
    You haven't removed any of those fflush(stdin) calls.
    Why fflush(stdin) is wrong - Cprogramming.com

    You're still calling menu() recursively instead of using a while loop, or just simply returning.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2021
    Posts
    5
    I am very sorry, but can you show me on how to return to main menu using while loop instead of calling it recursion? I dont want the user to exit and the run again just to go to the main menu again. I am newbie and not very understand in this programming courses. This is only for my elective subject and we need to debug the source code as our final project. Please help me anyone otherwise i will fail for this course. T_T
    Below is my latest code. Sorry for causing inconvenience.

    Code:
    #include<stdio.h>
    //#include<conio.h>
    #include<string.h>
    #include<stdlib.h>
    //#include<windows.h>
    
    
    struct person
    {
        char name[50];
        char address[50];
        char father_name[35];
        char mother_name[30];
        long int mble_no;
        char sex[8];
        char mail[100];
        char ic_no[20];
    
    
        };
    void menu();
    void got();
    void start();
    void back();
    void addrecord();
    void listrecord();
    void editrecord();
    void deleterecord();
    void searchrecord();
    int main()
    {
        system("color 2f");
        start();
        return 0;
    }
    void back()
    {
        start();
    }
    void start()
    {
        menu();
    }
    void menu()
    {
        system("cls");
        printf("\n\n\t=========================================\n");
        printf("\t**********WELCOME TO PHONEBOOK***********\n");
        printf("\t=========================================\n");
        printf("\n\n\tMAIN MENU\t\t\n");
        printf("\n\t1. Add New Contact \n\n\t2. List All Contacts \n\n\t3. Edit Existing Contact \n\n\t4. Search Contact \n\n\t5. Delete Contact \n\n\t6. Exit \n\n\n\n\tENTER NO OF CHOICE : ");
    
    
    switch(getch())
    {
        case '1': addrecord();
        break;
       case '2': listrecord();
        break;
        case '3': editrecord();
        break;
        case '4': searchrecord();
        break;
        case '5': deleterecord();
        break;
        case '6': exit(0);
        break;
        default:
                    system("cls");
                    printf("\n\n\n\tERROR: ENTER NO 1 TO 6 ONLY!");
                    printf("\n\n\tEnter any key to return to main menu. ");
                    getch();
    
    
    menu();
    }
    }
            
            void addrecord()
    {
            char another='Y';
            system("cls");
            FILE *f;
            struct person p;
            while((another=='Y')||(another=='y')){
            system("cls");
            f=fopen("project","ab+");
            fseek(f,0,SEEK_END);
            fwrite(&p,sizeof(p),1,f);
            printf("\n\t===========================\n");
            printf("\t******ADD NEW CONTACT******");
            printf("\n\t===========================\n");
            printf("\n\tEnter name : ");
            gets(p.name);
            printf("\n\tEnter home address: ");
            gets(p.address);
            printf("\n\tEnter father's name: ");
            gets(p.father_name);
            printf("\n\tEnter mother's name : ");
            gets(p.mother_name);
            printf("\n\tEnter phone no (+60) : ");
            scanf("%ld",&p.mble_no);
            printf("\n\tEnter gender : ");
            scanf("%s",&p.sex);
            printf("\n\tEnter e-mail address : ");
            scanf("%s",&p.mail);
            printf("\n\tEnter IC No : ");
            scanf("%s",&p.ic_no);
            fwrite(&p,sizeof(p),1,f);
          //fflush(stdin);
            printf("\n\n\n\tCONTACT HAS BEEN SUCCESFULLY ADDED!");
            printf("\n\n\tWant to add Another Contact? ( Y : Yes / N : No ) ---> ");
    //fflush(stdin);
    another=getche();
     }
     if(another!='Y'||(another!='y')){
    fclose(f);
        system("cls");
        menu();
     }
    }
    
    
    void listrecord(FILE *f)
    {
    int count=0;
    char keyPress;
    struct person p;
    f=fopen("project","rb");
    system("cls");
    printf("\n\t=============================\n");
    printf("\t******ALL CONTACT LIST******");
    printf("\n\t=============================\n");
    while(fread(&p,sizeof(p),1,f)==1){
        count++;
        printf("\n\n\n\tName = %s\n\n\tAddress = %s\n\n\tFather's name = %s\n\n\tMother's name = %s\n\n\tPhone no (+60) = %ld\n\n\tGender = %s\n\n\tE-mail = %s\n\n\tIC No = %s",p.name,p.address,p.father_name,p.mother_name,p.mble_no,p.sex,p.mail,p.ic_no);
        printf("\n\n\t-------------------------------------------------------------------");
      }
       if(count==0){
       printf("\n\n\n\tLIST STILL EMPTY. NOTHING TO DISPLAY!");
      }
    fclose(f);
        printf("\n\n\n\t\t- END OF LIST -\n");
        printf("\n\tEnter any key to return to main menu. ");
        getch();
        system("cls");
        menu();
    }
    
    
    void searchrecord()
    {
        int count=0;
        struct person p;
        FILE *f;
        char name[100];
        f=fopen("project","rb");
        if(f==NULL)
            {
              printf("\n\n\n\tERROR IN SEARCHING!\a\a\a\a");
            }
    system("cls");
    printf("\n\t===========================");
    printf("\n\t******SEARCH CONTACT******");
    printf("\n\t===========================\n");
    printf("\n\n\tENTER CONTACT NAME TO SEARCH : ");
    gets(name);
    while(fread(&p,sizeof(p),1,f)==1){
    if(strcmp(strupr(p.name),strupr(name))==0){
        count++;
        system("cls");
            printf("\n\n\n\tDetail Information About: %s",name);
            printf("\n\n\n\tName = %s\n\n\tAddress = %s\n\n\tFather's name = %s\n\n\tMother's name = %s\n\n\tPhone no (+60) = %ld\n\n\tGender = %s\n\n\tE-mail = %s\n\n\tIC No = %s",p.name,p.address,p.father_name,p.mother_name,p.mble_no,p.sex,p.mail,p.ic_no);
    }
     }
       if ( count == 0 )
    {
          printf("\n\n\tERROR: CONTACT FOR NAME %s IS NOT FOUND!", name);
        //else
        //printf("\n\n\tERROR: CONTACT FOR NAME %s IS NOT FOUND!",name);
       }
       fclose(f);
       printf("\n\n\tEnter any key to return to main menu. ");
       getch();
       system("cls");
       menu();
    }
    
    
    void deleterecord()
    {
        struct person p;
        FILE *f,*ft;
    	int flag;
    	char name[100];
    	f=fopen("project","rb");
    	if(f==NULL)
    		{
    			printf("\n\n\tCONTACT'S DATA NOT ADDED YET.");
    		}
    	else
    	{
    		ft=fopen("temp","wb+");
    		if(ft==NULL)
                printf("\n\n\tCONTACT'S DATA NOT ADDED YET!");
    		else
            {
            system("cls");
            printf("\n\t===========================");
            printf("\n\t******DELETE CONTACT******");
            printf("\n\t===========================\n");
    		printf("\n\n\tENTER CONTACT NAME TO DELETE : ");
    		gets(name);
    		//fflush(stdin);
    		while(fread(&p,sizeof(p),1,f)==1)
    		{
    			if(strcmp(strupr(p.name),strupr(name))!=0)
    				fwrite(&p,sizeof(p),1,ft);
    			if(strcmp(p.name,name)==0)
                    flag=1;
    		}
    	fclose(f);
    	fclose(ft);
    	if(flag!=1)
    	{
    		printf("\n\n\tCONTACT NOT FOUND!");
    		remove("temp");
    	}
    		else
    		{
    			remove("project");
    			rename("temp","project");
    			printf("\n\n\n\n\tCONTACT'S RECORD SUCCESSFULLY DELETED.");
    		}
    	}
    }
         printf("\n\n\tEnter any key to return to main menu. ");
    	 getch();
        system("cls");
    menu();
    }
    
    
    void editrecord()
    {
        int c;
        FILE *f;
        int flag=0;
        struct person p,s;
        system("cls");
    	char  name[50];
    	f=fopen("project","rb+");
    	if(f==NULL)
    		{
    			printf("\n\n\tCONTACT'S DATA NOT ADDED YET.");
    		}
    	else
    	{
    	    system("cls");
    		printf("\n\n\tENTER CONTACT NAME TO EDIT : ");
                gets(name);
                while(fread(&p,sizeof(p),1,f)==1)
                {
                    if(strcmp(strupr(name),strupr(p.name))==0)
                    {
                        printf("\n\n\t=================================");
                        printf("\n\t******EDIT EXISTING CONTACT******");
                        printf("\n\t=================================\n");
                        printf("\n\tEnter name : ");
                        gets(s.name);
                        printf("\n\tEnter home address: ");
                        gets(s.address);
                        printf("\n\tEnter father's name: ");
                        gets(s.father_name);
                        printf("\n\tEnter mother's name : ");
                        gets(s.mother_name);
                        printf("\n\tEnter phone no (+60) : ");
                        scanf("%ld",&s.mble_no);
                        printf("\n\tEnter gender : ");
                        scanf("%s",&s.sex);
                        printf("\n\tEnter e-mail address : ");
                        scanf("%s",&s.mail);
                        printf("\n\tEnter IC No : ");
                        scanf("%s",&s.ic_no);
                        //printf("\n\n\n\t=================================");
                        //printf("\n\t******EDIT EXISTING CONTACT******");
                        //printf("\n\t=================================\n");
                        //printf("\n\tEnter name: ");
                        //got(s.name);
                        //printf("\n\n\tEnter address: ");
                        //got(s.address);
                        //printf("\n\n\tEnter father name: ");
                        //got(s.father_name);
                        //printf("\n\n\tEnter mother name: ");
                        //got(s.mother_name);
                        //printf("\n\n\tEnter phone no (+60) : ");
                        //scanf("%ld",&s.mble_no);
                        //printf("\n\tEnter sex: ");
                        //got(s.sex);
                        //printf("\n\n\tEnter e-mail: ");
                        //got(s.mail);
                        //printf("\n\n\tEnter IC no : ");
                        //got(s.ic_no);
                        fseek(f,-sizeof(p),SEEK_CUR);
                        fwrite(&s,sizeof(p),1,f);
                        flag=1;
                        break;
                    }
                    //fflush(stdin);
                }
                if(flag==1)
                {
                    printf("\n\n\n\tCONTACT RECORD SUCCESSFULLY MODIFIED!");
                }
                else
                {
                    printf("\n\n\n\tCONTACT FOR THE NAME: %s IS NOT FOUND!",name);
    
    
                }
                fclose(f);
    	}
    	 printf("\n\n\tEnter any key to return to main menu. ");
    	 getch();
         system("cls");
    	 menu();
        }
    
    
    void got(char *name)
    {
    
    
       int i=0,j;
        char c,ch;
        do
        {
            c=getch();
                    if(c!=8&&c!=13)
                    {
                        *(name+i)=c;
                            putch(c);
                            i++;
                    }
                    if(c==8)
                    {
                        if(i>0)
                        {
                            i--;
                        }
                       // printf("h");
                        system("cls");
                        for(j=0;j<i;j++)
                        {
                            ch=*(name+j);
                            putch(ch);
    
    
                        }
    
    
                    }
        }while(c!=13);
          *(name+i)='\0';
    
    
    }
    Last edited by tomatogrower; 01-24-2021 at 10:35 PM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Like this.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    void addorder() {
      int done = 0;
      int category;
      do {
        printf("The add order\n");
        printf("Choose > ");
        fflush(stdout);
        scanf("%d",&category);
        switch( category ) {
          case 1:
            // something
            break;
          case 2:
            // something else
            break;
          default:
            done = 1;
            break;
        }
      } while ( !done );
    }
    
    void deleteorder() {
    }
    
    void updateorder() {
    }
    
    void searchmenu() {
    }
    
    void displaycart() {
    }
    
    void checkout() {
    }
    
    void menu() {
      int service;
      do {
        printf("The menu\n");
        printf("Choose > ");
        scanf("%d",&service);
        switch(service)
        {
          case 1:
            addorder();
            break;
    
          case 2:
            deleteorder();
            break;
    
          case 3:
            updateorder();
            break;
    
          case 4:
            searchmenu();
            break;
    
          case 5:
            displaycart();
            break;
    
          case 6:
            checkout();
            break;
        }
      } while ( service != 6 );
    }
    
    int main ( ) {
      menu();
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jan 2021
    Posts
    5
    thank you Salem for your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some help on last part of program
    By coder121 in forum C Programming
    Replies: 2
    Last Post: 01-30-2017, 07:25 PM
  2. Help with part of program
    By mytrademark in forum C Programming
    Replies: 3
    Last Post: 10-13-2011, 03:24 PM
  3. why the control goes to else part in this program
    By vapanchamukhi in forum C Programming
    Replies: 2
    Last Post: 01-13-2009, 07:09 AM
  4. Replies: 3
    Last Post: 12-17-2003, 06:02 PM
  5. How do you branch to another part of the program?
    By gcn_zelda in forum C++ Programming
    Replies: 3
    Last Post: 03-16-2003, 12:27 PM

Tags for this Thread