Thread: Help with my program!

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    3

    Help with my program!

    Code:
     
    
    for (j=0; j<j+1; j++) {
    
    fscanf(ifp, "%d%d%d%lf", &month, &day, &year, &temp);
    
    if (month = wedMonth) {
    daysInMonth++;
    sumMonthly += temp;
    }
    
    if (day == wedDay && month == wedMonth) {
    numDays++;
    sumDays += temp;
    }
    
    else if (day == -1)
    break;
    }
    fclose(ifp);
    return 0;
    }
    
    
    My loop was working fine before I added the first if statement to the begginning. Without that first if statement, it works.
    Last edited by b2thompson; 10-13-2011 at 04:35 PM.

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    3
    Oh I forgot to add: at the end of the data file there are four "-1" which is why I put the if statement to break out of the loop if day was -1

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    "=" is NOT the same as "=="

    Code:
    if (month = wedMonth) {
    Code:
    if (month == wedMonth) {

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    3
    thank you! I had to delete my post because I'm not sure if my teacher would want me to post my code online..is there a way to delete it completely?

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    No, but there is a way for me to get the mods to put it back in so we can actually see it. No one wants to see a bunch of half empty threads because some dude decided to try and un-type on the internet.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    To b2thompson,

    Dont report those thread because you dont want others to see your code. You post it online, its no longer private. People post answers to help everyone, not to give you an individual advantage.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 11-03-2010, 12:45 PM
  2. Replies: 1
    Last Post: 03-03-2009, 04:47 PM
  3. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  4. Replies: 5
    Last Post: 08-16-2007, 11:43 PM
  5. Replies: 18
    Last Post: 11-13-2006, 01:11 PM