-
Parse Errors
I recently switched over to Dev-C++ from Miracle C. I have a program that I first entered using Miracle C, but when the compiler told me that the source file was too big, I reentered it into Dev-C++ using the editor included with this product. I have got the program down to one error indicating a parse error. I have looked at my source through different editors just to make sure that there isn't a bad character anywhere, but can't find any. Would you like me to include the program source, or does anyone know why this type of error can occur?
-
There are so many reasons for a parse error its not even funny. Basically it means it saw something where it wasn't expected. I suggest you post the code and include the exact error. If possible highlight the line were the error was reported.
-
Yeah, at least 9 times out of 10 a parse error is because of a typo. Definately post your code and the error message, although if its really long code just post the section where the compiler says the error is.
-
Parse Errors
The error message I get is :
896 c:\dev-c_~1\examples\curren~1.cpp parse error before '{'
I am including some lines of code prior to this eror and after to see if any of you can figure out what the error is.
Code:
if( strcmp(Menu_Opt, "Y02") == 0)
{
float AUD_Menu();
}
if( strcmp(Menu_Opt, "Y03") == 0)
{
float BRL_Menu();
}
if( strcmp(Menu_Opt, "Y04") == 0)
{
float GBP_Menu();
}
if( strcmp(Menu_Opt, "Y05") == 0)
{
float CAD_Menu();
}
if( strcmp(Menu_Opt, "Y06") == 0)
{
float CNY_Menu();
}
if( strcmp(Menu_Opt, "Y07") == 0)
{
float DKK_Menu();
}
if( strcmp(Menu_Opt, "Y08") == 0)
{
float EUR_Menu();
}
if( strcmp(Menu_Opt, "Y09") == 0)
{
float HKD_Menu();
}
if( strcmp(Menu_Opt, "Y10") == 0)
{
float INR_Menu();
}
if( strcmp(Menu_Opt, "Y11") == 0)
{
float JPY_Menu();
}
if( strcmp(Menu_Opt, "Y12") == 0)
{
float MYR_Menu();
}
if( strcmp(Menu_Opt, "Y13") == 0)
{
float MXN_Menu();
}
if( strcmp(Menu_Opt, "Y14") == 0)
{
float NZD_Menu();
}
if( strcmp(Menu_Opt, "Y15") == 0)
{
float NOK_Menu();
}
if( strcmp(Menu_Opt, "Y16") == 0)
{
float SGD_Menu();
}
if( strcmp(Menu_Opt, "Y17") == 0)
{
float ZAR_Menu();
}
if( strcmp(Menu_Opt, "Y18") == 0)
{
float KRW_Menu();
}
if( strcmp(Menu_Opt, "Y19") == 0)
{
float LKR_Menu();
}
if( strcmp(Menu_Opt, "Y20") == 0)
{
float SEK_Menu();
}
if( strcmp(Menu_Opt, "Y21") == 0)
{
float CHF_Menu();
}
if( strcmp(Menu_Opt, "Y22") == 0)
{
float TVD_Menu();
}
if( strcmp(Menu_Opt, "Y23") == 0)
{
float THB_Menu();
}
if( strcmp(Menu_Opt, "Y24") == 0)
{
float YEB_Menu();
}
float AUD_Menu()
{
printf("Currency Conversion\n");
printf("Australian Dollars Conversion Menu\n\n");
printf("B01. AUD to USD Y01. Transfer to USD Conversion Menu\n");
printf("B02. AUD to BRL\n");
printf("B03. AUD to GBP Y03. Transfer to BRL Conversion Menu\n");
printf("B04. AUD to CAD Y04. Transfer to GBP Conversion Menu\n");
printf("B05. AUD to CNY Y05. Transfer to CAD Conversion Menu\n");
896 is the { right after the float AUD_Menu() statement. I hope that this helps in finding the error. AUD_Menu, and all the other *_Menu statements are function calls. Maybe I am not using the function call properly?
-
Well assuming all your strcmp() calls are actually inside a function, that function is missing a closing }
-
Parse Errors
I guess working on the program until 2:30 A.M. and then back to it to fix other errors I got blinded by it. Thanks! :)
-
It should also be mentioned that since these:
float AUD_Menu();
float MXN_Menu();
...
are function declarations, they do nothing and the app will not act as you think it will. Remove the return type. Better yet, confirm that the first letter in the string is a 'Y', parse the remaining string into an integer (atoi) and then use the result as an index into a jump map. These endless ifs make my head swim.
-
Can you please let me know what you mean by removing the return type. I'm not sure exactly what you mean.
-
AUD_Menu();
instead of
flaot AUD_Menu();
-
Parse Errors
Now I get an error message of ANSI C++ forbids declaration 'AUD_Menu' with no type.
-
Oh. Well, that means you just haven't got a function called AUD_Menu() defined/declared. Once you've actually created the functions (as you should), the error should go away.
-
When you don't have a return type, you put void where it should be.
-
homeyg, try reading the code before posting WRONG ADVICE. Putting a 'void' in there will simply return us to the original problem that CornedBee mentioned.
-
I believe I have function defined/declared. Please see my sample code from above to show that I do. If this isn't right, please let me know.
-
>Please see my sample code from above to show that I do.
Judging from your very incomplete example, either you're trying to use non-initialization statements in the global namespace, or you're trying to define nested functions. Both are illegal in C++. Even if it did work, barring prototypes (which I can't see because you didn't post a complete program), your functions are used before they're declared. This is a bad thing too.