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
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    Code:
    &pdate->day <= 31 && &pdate->day >= 1
    ampersands should be removed
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    20,968
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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