need some more help with interegers in loops.

This is a discussion on need some more help with interegers in loops. within the C Programming forums, part of the General Programming Boards category; inside my function, i need these statements to work. the function is. void enter(struct date *pdate, char desc[ ]) Code: ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    47

    need some more help with interegers in loops.

    inside my function, i need these statements to work.
    the function is.

    void enter(struct date *pdate, char desc[ ])



    Code:
     check = 0;
      while(check != 1)
        {
            printf("Enter the day: (between 1 and 31) ");
            scanf("%d", &pdate->day);
            if (&pdate->day <= 31 && &pdate->day >= 1)
            {
                break;
            }
        }

    im getting the error.
    ISO C++ forbids the comparison between pointers and intergers.

    how would i fix this?

  2. #2
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,754
    Code:
    &pdate->day <= 31 && &pdate->day >= 1
    ampersands should be removed
    To be or not to be == true

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,618
    Except for the one in the scanf() call, change &pdate->day to pdate->day. You do not want to compare the address of pdate->day, but the value of pdate->day.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    47
    makes sense ill give it a try

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Too many loops D:
    By F5 Tornado in forum C++ Programming
    Replies: 6
    Last Post: 12-03-2007, 12:18 AM
  2. strings and loops...
    By twomers in forum C Programming
    Replies: 5
    Last Post: 12-12-2005, 10:28 AM
  3. help with arrays and loops
    By jdiazj1 in forum C Programming
    Replies: 4
    Last Post: 11-24-2001, 03:28 PM
  4. for loops in C
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 10-15-2001, 05:09 PM
  5. exiting loops with ease?
    By KingRuss in forum Game Programming
    Replies: 3
    Last Post: 09-24-2001, 08:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21