Parse Error, expecting `SEP'

This is a discussion on Parse Error, expecting `SEP' within the C Programming forums, part of the General Programming Boards category; line 11: Parse Error, expecting `SEP' 'const int TARGET_YEAR = 2010' Can explain this error to me? I'm copied this ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    15

    Parse Error, expecting `SEP'

    line 11: Parse Error, expecting `SEP'
    'const int TARGET_YEAR = 2010'

    Can explain this error to me? I'm copied this code straight from my book and double checked it to make sure.

    My program gets your weight, converts it to grams, and tells how old you will be in 2010 (demonstration of constants) Here is my code:
    PHP Code:
    /* Demonstrates variables and constants */
    #inlcude <stdio.h>

    /* Program end variable */
    int ch;

    /* Define a constant to convert from pounds to grams */
    #define GRAMS_PER_POUND 454

    /* Define a constant for the start of the next century */
    const int TARGET_YEAR 2010;

    /* Declare the needed variables */
    long weight_in_gramsweight_in_pounds;
    int year_of_birthage_in_2010;

    int main()
    {
        
    /* Input data from user */
        
        
    printf("Enter your weight in pounds: ");
        
    scanf("%d". &year_of_birth);
        
        
    /* Perform conversions */
        
        
    weight_in_grams weight_in_pounds GRAMS_PER_POUND;
        
    age_in_2010 TARGET_YEAR year_of_birth;
        
        
    /* Display results on the screen */
        
        
    printf("\nYour weight in grams = %ld"weight_in_grams);
        
    printf("\nIn 2010 you will be %d years old\n"age_in_2010);
        
        
    /* Hit Enter to end program */
        
    printf ("\nPress [Enter] to continue");
        While ((
    ch getchar()) != '\n' && ch != EOF);
        return(
    0);


  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You can't spell #include You have a dot instead of a comma in a scanf() call, and you've used a capital W for a while statement.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    15
    Wow, I feel stupid. I guess it takes someone else seeing things sometimes though. Thanks.

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    15
    Still getting the same error, heres an updated version of my code. Two lines I had left out are in there now:
    PHP Code:
    /* Demonstrates variables and constants */
    #include <stdio.h>

    /* Program end variable */
    int ch;

    /* Define a constant to convert from pounds to grams */
    #define GRAMS_PER_POUND 454

    /* Define a constant for the start of the next century */
    const int TARGET_YEAR 2010;

    /* Declare the needed variables */
    long weight_in_gramsweight_in_pounds;
    int year_of_birthage_in_2010;

    int main()
    {
        
    /* Input data from user */
        
        
    printf("Enter your weight in pounds: ");
        
    scanf("%d", &weight_in_pounds);
        
    printf("\nEnter your year of birth: ");
        
    scanf("%d", &year_of_birth);
        
        
    /* Perform conversions */
        
        
    weight_in_grams weight_in_pounds GRAMS_PER_POUND;
        
    age_in_2010 TARGET_YEAR year_of_birth;
        
        
    /* Display results on the screen */
        
        
    printf("\nYour weight in grams = %ld"weight_in_grams);
        
    printf("\nIn 2010 you will be %d years old\n"age_in_2010);
        
        
    /* Hit Enter to end program */
        
    printf ("\nPress [Enter] to continue");
        while ((
    ch getchar()) != '\n' && ch != EOF);
        return(
    0);


  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    What compiler are you using? It compiles fine for me (MSVC 6.0).
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    Registered User
    Join Date
    May 2003
    Posts
    15
    I'm using the Miracle C compiler.

  7. #7
    Registered User
    Join Date
    May 2003
    Posts
    15
    This is probably a very stupid question, but since C and C++ compilers are grouped together, are they usable for both languages?

  8. #8
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    not always, most major compiliers support both but i have found some that dont, they are strickly c, or visa versa. but they are very very basic.
    The keyboard is the standard device used to cause computer errors!

  9. #9
    Registered User
    Join Date
    May 2003
    Posts
    15
    Now that I switched to Dev C++ my "Press Enter to terminate" part of my code (on the FAQ page) no longer works. I still need to know a solution to the problem, what can I do now?

  10. #10
    eh ya hoser, got a beer? stumon's Avatar
    Join Date
    Feb 2003
    Posts
    323
    lol, that part is generated by the compiler, and its actually system/compiler dependent because you may find it works on 98, but not 2k, and so forth. you can always use the getch() function right before return to wait for a keypress. check out the faq
    The keyboard is the standard device used to cause computer errors!

  11. #11
    Registered User
    Join Date
    May 2003
    Posts
    15
    No you misunderstood me. I had to add the code in on my own using the information gained from the FAQ. Now that I switched compilers, the FAQ code no longer works.

  12. #12
    Registered User
    Join Date
    Oct 2002
    Posts
    385
    Or you can just run everything from the command line and not have to worry about adding code to pause the program so you can see what you've done.
    Wandering aimlessly through C.....

    http://dbrink.phpwebhosting.com

  13. #13
    Registered User
    Join Date
    May 2003
    Posts
    15
    I could do that but I want a way to add that in myself so that I don't have to do that.

  14. #14
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    If your code is still the same as the latest post, you have something like this.
    Code:
        /* ... */
        scanf("%d", &year_of_birth);
    
        /* ... */
    
        /* Hit Enter to end program */
        printf ("\nPress [Enter] to continue");
        while ((ch = getchar()) != '\n' && ch != EOF);
    The newline will remain in the input buffer following the call to scanf (Q12.18). You need to Flush the input buffer.
    Code:
        /* ... */
        scanf("%d", &year_of_birth);
    
        /* ... */
    
        while ((ch = getchar()) != '\n' && ch != EOF); /* flush input buffer */
        /* Hit Enter to end program */
        printf ("\nPress [Enter] to continue");
        while ((ch = getchar()) != '\n' && ch != EOF);
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  15. #15
    Registered User
    Join Date
    Oct 2002
    Posts
    385
    Originally posted by Undeadenemy
    I could do that but I want a way to add that in myself so that I don't have to do that.
    Seems like a lot of extra unneeded code to add and not very good coding technique at that. Just my opinion though.
    Wandering aimlessly through C.....

    http://dbrink.phpwebhosting.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  2. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM

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