Closed Thread
Results 1 to 7 of 7

Thread: Getting nothing

  1. #1
    hbk
    hbk is offline Learning Programmer
    Join Date
    Mar 2010
    Posts
    68
    Rep Power
    0

    Getting nothing

    Thanks for all the help so far.
    I am now trying to scanf the file in a sturcture called det and then add up some of the vlues from the stucture but when i run the program ,my compiler is basically crashing.

    A can't seem to find the problem.

    Code:
    void displayreport(void)
    {
             
         FILE *doc;
         
             
         int found =0,fees=0,collected=0,health=0;
         
         doc=fopen("transaction.txt","r");
         
         if (doc==NULL)
            printf("\n\n\t\t FILE NOT FOUND");
         else
         {
             while(!feof(doc))
                          {
                                        
                            fscanf(doc,"%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);
                            found++; 
                            
                            fees = det.fees + fees;
                            collected = det.collect + collected; 
                            health = det.insure + health;          
                            
                          }  
                          
                          
                                      
          }   
          
          printf("\n\n\t\t THE INCOME REPORT IS GENERTATED BELOW IS:\n");
          printf("\n\t\t THE NUMBER OF PATIENTS ARE:%d",found);
          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(doc);
         
    }

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Getting nothing

    What does the compiler output?

  4. #3
    hbk
    hbk is offline Learning Programmer
    Join Date
    Mar 2010
    Posts
    68
    Rep Power
    0

    Re: Getting nothing

    basically its crashing and trying to find a solution the the problem. i am getting nothing

  5. #4
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Getting nothing

    What compiler are you using?

  6. #5
    dcs
    dcs is offline Guru
    Join Date
    Mar 2008
    Posts
    775
    Rep Power
    23

    Re: Getting nothing

    Correctly use *scanf arguments -- provide a pointer where pointers are expected.
    Avoid loop control using eof.

    Something like this:
    Code:
          while ( fscanf(doc, "%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++; 
             /* ... */
    but when i run the program ,my compiler is basically crashing.
    As an aside, learn to describe better what you are talking about. There is compile time, link time, and run time. If if compiles, the "compiler is basically crashing" is terribly wrong. When it compiles fine and links fine, then you've got a run time error. Telling people that it's a compiler issue will only get you further from an answer -- so don't make things up. Run time issues are a different set of problems with different solutions; if you don't know what you're talking about, try to post only what you do know. ;P

  7. #6
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Getting nothing

    Telling people that it's a compiler issue will only get you further from an answer -- so don't make things up. Run time issues are a different set of problems with different solutions; if you don't know what you're talking about, try to post only what you do know. ;P
    I was trying to get him to figure that out himself.

  8. #7
    hbk
    hbk is offline Learning Programmer
    Join Date
    Mar 2010
    Posts
    68
    Rep Power
    0

    Re: Getting nothing

    Thanks a lot, and also for the explanation. now i realized it was definitely a run time error.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts