Jump to content

Not giving desired output

- - - - -

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

#1
hbk

hbk

    Learning Programmer

  • Members
  • PipPipPip
  • 71 posts
I am scannning the contents of file and then performing some simple operations.

First i want to scan the file for a particular doctor name that works.

I have two records in the file but its not incrementing the counter to check patients which belong to that doctor and add up fees.

case 1:{

                                        

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

                                         

                                         while(!feof(customer1) && 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)

                                                 {

                                                   count++;

                                                   fees = det.fees + fees;

                                                   collected = det.collect + collected;                                                                                                                                

                                                   Found=1;

                                                 }                                            

                                            

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

                                                 

                                           }

                                           printf("\n\t\t  DOCTORS NAME:%s",doctor1); 

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

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

                                           printf("\n\t\t  TOTAL FEE CHARGED:$ %d",fees);

                                           printf("\n\t\t  AMOUNT PAID:$ %d",det.collect);

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

                                        

                                          }

                                          break;


Heres a view of what the file looks like.


Dr.Robert.Williams 1 John.Grisam Cleaning 4/07/09 4500 3400 0 -1100

Dr.Robert.Williams 2 John.Whyte Cleaning 4/07/09 4500 3400 0 -1100




#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
It looks like your current code just lists the data. What is it supposed to do?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog