Error

Hybrid View

  1. #1
    Pikachu's Flea Collar Reputation: 10

    Join Date
    Apr 2010
    Posts
    56
    Rep Power
    4

    Default Error

    Hello, I was trying this "something" and I get this error:

    '{' : missing function header (old-style formal list?)

    Here's the code:

    #include "stdafx.h"
    #include <time.h>
    #include <iostream>

    using namespace std;



    int tm_min;
    int tm_hour;
    int tm_mon;
    int tm_year;

    int main();
    {

    time_t rawtime;
    struct tm * timeinfo;


    /* Prompt user for date */
    printf ("Enter the year: "); scanf ("%d",&year);
    printf ("Enter the month: "); scanf ("%d",&month);
    printf ("Enter the day: "); scanf ("%d",&day
    time_t start,end;

    /* Get current timeinfo and modify it to user's choice */
    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    timeinfo->tm_sec = sec - 60;
    timeinfo->tm_min = min - 60;
    timeinfo->tm_hour = hour - 24;
    timeinfo->tm_mon = month - 1;
    timeinfo->tm_year = year - 1900;

    /* Prompt user with time left until the user's date */
    mktime ( timeinfo );

    printf ("Time left until that date: %s.\n", timeleft[timeinfo->tm_hour]);

    return 0
    }

  2. #2
    Crumbly, yet Good Reputation: 75
    Eriond's Avatar
    Join Date
    May 2006
    Location
    Montreal
    Posts
    1,798
    Rep Power
    0

    Default

    Gotta take out the semi-colon after the int main().
    THIS MA SIGNATURE

  3. #3
    Pikachu's Flea Collar Reputation: 10

    Join Date
    Apr 2010
    Posts
    56
    Rep Power
    4

    Default

    Ok, when I remove it I get these errors:

    error C2065: 'year' : undeclared identifier (same with month, day, minute, second)
    also error C2563: mismatch in formal parameter list
    and error C2146: syntax error : missing ')' before identifier 'time_t'
    and error C2143: syntax error : missing ';' before '}'

  4. #4
    Crumbly, yet Good Reputation: 75
    Eriond's Avatar
    Join Date
    May 2006
    Location
    Montreal
    Posts
    1,798
    Rep Power
    0

    Default

    You can solve all those first errors by declaring your variables beforehand. See that page I PM'd you for details.

    As for the second error, make sure you always have a closing parenthesis and a closing square bracket. In this case, you're leaving a parenthesis open.
    THIS MA SIGNATURE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •