Jump to content

Detect the error

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
hbk

hbk

    Learning Programmer

  • Members
  • PipPipPip
  • 71 posts
I am reading data from a file but i am then comparing it with a another data item but the compiler is not printing to screen what i ask it to.

void doctorrecord(void)

{

    system("color 2"); 

  

    

  char Target[50];

  int tell=0;

  int Found=0,count1=0,count2=0,count3=0;

  char doctor1[30],doctor2[30],doctor3[30];

  int health=0,fees=0,collected=0;

  

  

  strcpy(doctor1,"Dr.Robert.Willimas");

  strcpy(doctor2,"Dr.James.Brown");

  strcpy(doctor3,"Dr.John.Whyte");

 

               

              if((customer1=fopen("transaction.txt","r"))==NULL)

                   printf("THE FILE IS EMPTY");

              else

              {

                          

                  

                  while(fscanf(customer1,"%s %s %s %s %s %d %d %d %d",det.name,det.regis,det.pname,det.treatment,det.piont,&det.fees,&det.collect,&det.insure,&det.balance)==9                 

                    && Found==0)

                      {                              

                                                

                        //fscanf(customer1,"%s %s %s %s %s %d %d %d %d",det.name,det.regis,det.pname,det.treatment,det.piont,&det.fees,&det.collect,&det.insure,&det.balance);

                       

                        if(strcmp(doctor1,det.name)==0)

                        {

                               {

                                   count1++;                               

                                   Found=1;

                        

                                   fees = det.fees + fees;

                                   collected = det.collect + collected; 

                                   health = det.insure + health;                         

                        

                                 }

                                

                     

                                 if(Found)

                                {                                          

                           

                                    printf("\n\t\t  NAME:%s",det.pname);                                     

                                }

                                

                                    printf("\n\t\t  NUMBER OF PATIENTS:%d",count1);

                                    printf("\n\t\t  TREATMENT:%s",det.treatment); 

                                    printf("\n\t\t  TOTAL FEES ARE:$ %d",fees);

                                    printf("\n\t\t  TOTAL FEES COLLECTED:$ %d",collected);

                                    printf("\n\t\t  TOTAL HEALTH INSURANCE FEES:$ %d",health); 

                       }

                       

                        else if(strcmp(doctor2,det.name)==0)

                        {

                               {

                                   count2++;                               

                                   Found=1;

                        

                                   fees = det.fees + fees;

                                   collected = det.collect + collected; 

                                   health = det.insure + health;                         

                        

                                 }

                                

                     

                                 if(Found)

                                {                                          

                           

                                    printf("\n\t\t  NAME:%s",det.pname);

                                    printf("\n\t\t  NUMBER OF PATIENTS:%d",count);

                                    printf("\n\t\t  TREATMENT:%s",det.treatment); 

                                    printf("\n\t\t TOTAL FEES ARE:$ %d",fees);

                                    printf("\n\t\t TOTAL FEES COLLECTED:$ %d",collected);

                                    printf("\n\t\t TOTAL HEALTH INSURANCE FEES:$ %d",health);  

                                }

                       }

                       else if(strcmp(doctor3,det.name)==0)

                        {

                               {

                                   count3++;                               

                                   Found=1;

                        

                                   fees = det.fees + fees;

                                   collected = det.collect + collected; 

                                   health = det.insure + health;                         

                        

                                 }

                                

                     

                                 if(Found)

                                {                                          

                           

                                    printf("\n\t\t  NAME:%s",det.pname);

                                    printf("\n\t\t  NUMBER OF PATIENTS:%d",count);

                                    printf("\n\t\t  TREATMENT:%s",det.treatment); 

                                    printf("\n\t\t TOTAL FEES ARE:$ %d",fees);

                                    printf("\n\t\t TOTAL FEES COLLECTED:$ %d",collected);

                                    printf("\n\t\t TOTAL HEALTH INSURANCE FEES:$ %d",health);  

                                }

                       }

               

                }          

        

     

  

      fclose(customer1); 

     }

}             


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Without seeing the contents of both the file, and where it's not printing when you expect it to, we may not be able to help much.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
hbk

hbk

    Learning Programmer

  • Members
  • PipPipPip
  • 71 posts
Dr.Robert.Williams 1 John.Grisam Cleaning 4/07/09 4500 3400 0 -1100

This is what the file looks like.

#4
bobdark

bobdark

    Programmer

  • Members
  • PipPipPipPip
  • 164 posts
Dr.Robert's family name in the code appears to be Willimas and not Williams. That is probably the problem - it doesn't match any case.

#5
hbk

hbk

    Learning Programmer

  • Members
  • PipPipPip
  • 71 posts
That does'nt seem to be the answer

#6
bobdark

bobdark

    Programmer

  • Members
  • PipPipPipPip
  • 164 posts
In this case post your whole code.