Parse Errors

This is a discussion on Parse Errors within the C++ Programming forums, part of the General Programming Boards category; I recently switched over to Dev-C++ from Miracle C. I have a program that I first entered using Miracle C, ...

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    41

    Unhappy 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?

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    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.

  3. #3
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    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.

  4. #4
    Registered User
    Join Date
    Nov 2004
    Posts
    41

    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?
    Last edited by Salem; 12-12-2004 at 01:17 PM. Reason: Adding code tags :(

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,668
    Well assuming all your strcmp() calls are actually inside a function, that function is missing a closing }

  6. #6
    Registered User
    Join Date
    Nov 2004
    Posts
    41

    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!

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #8
    Registered User
    Join Date
    Nov 2004
    Posts
    41
    Can you please let me know what you mean by removing the return type. I'm not sure exactly what you mean.

  9. #9
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    AUD_Menu();
    instead of
    flaot AUD_Menu();
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  10. #10
    Registered User
    Join Date
    Nov 2004
    Posts
    41

    Parse Errors

    Now I get an error message of ANSI C++ forbids declaration 'AUD_Menu' with no type.

  11. #11
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    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.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  12. #12
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    When you don't have a return type, you put void where it should be.

  13. #13
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    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.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  14. #14
    Registered User
    Join Date
    Nov 2004
    Posts
    41
    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.

  15. #15
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >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.
    My best code is written with the delete key.

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. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM
  5. C Parse errors
    By aimalk in forum C Programming
    Replies: 5
    Last Post: 03-04-2002, 04:23 PM

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