compile errors with date program

This is a discussion on compile errors with date program within the C Programming forums, part of the General Programming Boards category; getting compile time errors when validating my date program. im kind of having problems with it im getting a token ...

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    compile errors with date program

    getting compile time errors when validating my date program.

    im kind of having problems with it im getting a token error.
    thats my function


    Code:
    void ageCalculator()
    {
     char buff[BUFSIZ];
     
     int m,d,y;
     struct tm t;
     time_t now;
     
     
    
     time(&now);
     t = *localtime(&now);
     strftime(buff, sizeof(buff), "%Y//%m//%y", &t);
    
     
     printf("Please enter your date of birth in (yyyy//mm/dd) format\n");
    
      if ( fgets( buff, BUFSIZ, stdin ) != NULL ) {
        int y,m,d;
        if ( sscanf( buff, "%d/%d/%d", &d, &m, &y ) == 3 ) {
          /* got 3 ints */
          if ( d >= 1 && d <= 31 ) /* etc etc */
        }
      }
      
      
     printf("The current date is %s\n",buff);
     
    
     
    }

  2. #2
    B26354 Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Quote Originally Posted by bazzano
    getting compile time errors when validating my date program.
    It would help to post the errors.

    Code:
    if ( sscanf( buff, "%d/%d/%d", &d, &m, &y ) == 3 ) {
          /* got 3 ints */
          if ( d >= 1 && d <= 31 ) /* etc etc */
        }
    This is a problem. The compiler is expecting a statement following the if condition.

    EDIT: I just realized where that code came from. Many of the people on this board are more than happy to point you in the right direction, but they are unlikely to write code for you. If you show a good faith effort and let us know where you're stuck, we can help.
    Last edited by Deckard; 08-07-2005 at 06:43 AM.
    Jason Deckard

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,541
    Heh - I think you avatar is more appropriate than mine at the moment

    Yes bazzano, that was a hint, not an answer I posted previously.
    It's up to you to make sure you understand what is actually going on and adapt it to make it suit your specific needs. This is one of the skills which make real programmers.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange compile errors
    By csonx_p in forum C++ Programming
    Replies: 10
    Last Post: 07-28-2008, 11:41 AM
  2. Compile errors in stl header files
    By Swordsalot in forum C++ Programming
    Replies: 2
    Last Post: 07-20-2008, 02:41 AM
  3. Using a makefile to compile a program using SDL
    By Noerbo in forum Game Programming
    Replies: 9
    Last Post: 04-30-2006, 09:11 AM
  4. logical errors when i compile.
    By findme in forum C++ Programming
    Replies: 4
    Last Post: 11-17-2005, 03:55 PM
  5. compile program?
    By Goosie in forum C++ Programming
    Replies: 9
    Last Post: 06-22-2005, 02:26 PM

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