# Parse Error, expecting `SEP'

• 05-11-2003
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_grams, weight_in_pounds; int year_of_birth, age_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); }  ```
• 05-11-2003
Hammer
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.
• 05-11-2003
Wow, I feel stupid. I guess it takes someone else seeing things sometimes though. Thanks.
• 05-11-2003
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_grams, weight_in_pounds; int year_of_birth, age_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); }  ```
• 05-11-2003
XSquared
What compiler are you using? It compiles fine for me (MSVC 6.0).
• 05-11-2003
I'm using the Miracle C compiler.
• 05-12-2003
This is probably a very stupid question, but since C and C++ compilers are grouped together, are they usable for both languages?
• 05-12-2003
stumon
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.
• 05-12-2003
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?
• 05-12-2003
stumon
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
• 05-13-2003
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.
• 05-13-2003
damonbrinkley
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.
• 05-13-2003
I could do that but I want a way to add that in myself so that I don't have to do that.
• 05-13-2003
Dave_Sinkula
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);```
• 05-13-2003
damonbrinkley
Quote:

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.