odd warning

Discussion in 'Mac Programming' started by farmerdoug, Jan 20, 2013.

  1. farmerdoug, Jan 20, 2013
    Last edited by a moderator: Jan 20, 2013

    macrumors 6502a

    Joined:
    Sep 16, 2008
    #1
    Code:
    int i, *tension;
    tension = (int *) calloc(MAX_READINGS, sizeof(int));
    if (fscanf(readings,"%s %d\n", reading_times[0], tension[0]) == EOF)
     
  2. macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    You didn't tell us what warning you're getting and we don't know anything about your reading_times[] variable.
     
  3. macrumors 603

    Joined:
    Aug 9, 2009
    #3
    fscanf() requires pointer-to-int for %d. What type is tension[0]?
     
  4. thread starter macrumors 6502a

    Joined:
    Sep 16, 2008
    #4
    thanks guys.
    I found the error while writing the post but couldn't find out how to delete it. I left out the & in front of tension[0].
     
  5. macrumors 68040

    Joined:
    Feb 2, 2008
    #5
    You probably do not want to test against EOF in *scanf functions, they return EOF only under very special circumstances. If you test against != 2, you will catch read errors and all other cases.
     
  6. macrumors 603

    Joined:
    Aug 9, 2009
    #6
    MacRumors FAQ: How do I edit or delete my post?

    To avoid having people answer or ask follow-up questions in the interval before the post is deleted, simply replace your entire post with the word "delete".
     

Share This Page