can anyone help??????

This is a discussion on can anyone help?????? within the C++ Programming forums, part of the General Programming Boards category; my mate is stucj again..... he gets an error saying "124 parse error error at end of input" here is ...

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475

    can anyone help??????

    my mate is stucj again..... he gets an error saying

    "124 parse error error at end of input"

    here is the code:

    /*
    #include <string.h>
    #include <windows.h> // included file types
    #include <iostream>
    using namespace std;

    void instructions();

    int weapons = 0;
    int lives = 1, maxDamage = 0, totDamage = 0;
    int magic = 0, maxMagic = 10, totMagic = 0;
    int ToTEnemies = 25;
    int ToTBosses = 3;
    int ToTLevels = 3;
    int PlayerHealth = 100; // varibles at start
    int NumberOfPlayers = 0;
    string levelname;
    int choice;
    int play;
    char pname[54];
    void level1();
    void level2();
    void level3();
    int selecta;

    int main()

    {

    printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    printf("\t\t|======================|======|\n");
    printf("\t\t| | | |\ | --- | |\n");
    printf("\t\t| | | | \ | | | |\n");
    printf("\t\t| |\ | | | |-- | |\n"); // tile screen
    printf("\t\t| | \ | | | ___| | |\n"); // unfinished
    printf("\t\t| | |\n");
    printf("\t\t|=============================|\n");

    cout << "\n\n";
    printf("programed by Peter Watts\n");
    cout << "\n\n";
    cout << "To play press 1 and return" << endl;
    cin >> play;
    NumberOfPlayers=NumberOfPlayers+1;
    system ("cls");
    cout << "\tMAIN MENU\n\n";
    cout << "\n\n";
    cout << "Press 1 to play\n";
    cout << "\n\n"; // main menu
    cout << "Press 2 to read instructions\n";
    cout << "\n\n";
    cout << "Press 3 to quit\n";
    cout << "\n\n";
    cin >> choice;

    switch (choice) {

    case 1:
    system ("cls");
    cout << "Please enter your first name: " << endl;
    cout << "\n\n";
    cin >> pname;
    system ("cls");
    cout << "Welcome " << pname;
    cout << "\n\n"; // brgining of game
    cout << "\n\n";
    printf("Please Enter a choice...\n");
    cout << "\n\n";
    printf ("Press 4 to explore your surroundings\n");
    cout << "\n\n";
    printf("Press 5 to attack\n");
    cout << "\n\n";
    cout << "Your Selection: " << endl;
    cin >> selecta;

    switch (selecta) {

    case 4:
    system ("cls");
    cout << "As you explore, you find a small knife." << endl;
    weapons=weapons+1;

    //old program code may or may not contain errors
    //after this point

    void level1();




    break;

    case 5:
    system ("cls");
    cout << "Theres Nothing to attack!!\n" << endl;
    break;

    case 2:
    system ("cls"); // instructions
    cout << "\tINSTRUCTIONS" << endl;
    cout << "\n\n";
    cout << "To Play Kimberly's Quest it could not be easier!\n" << endl;
    cout << "Just press the keys that are displayed on the screen\n" << endl;
    cout << "that correspond to the functions that need to be used.\n" << endl;
    cout << "In battle, you will given a different sort of menu,\n" << endl;
    cout << "but the means are the same.\n" << endl;
    cout << "BEST OF LUCK!\n" << endl;
    cout << "\n\n";
    break;

    case 3:

    cout << "See you soon!\n" << endl;
    break;
    // quit game or user wrong choice
    default:
    cout << "Incorrect Choice!\n" << endl;
    break;
    {
    system ("pause");
    {

    /*

  2. #2
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    sorry i forgot to use the code tags when i posted it!!!

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    *blinks*

    without indention i won't help, but one thing that stood out is void level1(); within a switch statement....i think

    edit the code with indention and provide a line number for the error
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475

    taged code to help you help me

    [code]
    // quite a challenge
    #include <string.h>
    #include <windows.h> // included file types
    #include <iostream>
    using namespace std;

    void instructions();

    int weapons = 0;
    int lives = 1, maxDamage = 0, totDamage = 0;
    int magic = 0, maxMagic = 10, totMagic = 0;
    int ToTEnemies = 25;
    int ToTBosses = 3;
    int ToTLevels = 3;
    int PlayerHealth = 100; // varibles at start
    int NumberOfPlayers = 0;
    string levelname;
    int choice;
    int play;
    char pname[54];
    void level1();
    void level2();
    void level3();
    int selecta;

    int main()

    {

    printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
    printf("\t\t|======================|======|\n");
    printf("\t\t| | | |\ | --- | |\n");
    printf("\t\t| | | | \ | | | |\n");
    printf("\t\t| |\ | | | |-- | |\n"); // tile screen
    printf("\t\t| | \ | | | ___| | |\n"); // unfinished
    printf("\t\t| | |\n");
    printf("\t\t|=============================|\n");

    cout << "\n\n";
    printf("programed by Peter Watts\n");
    cout << "\n\n";
    cout << "To play press 1 and return" << endl;
    cin >> play;
    NumberOfPlayers=NumberOfPlayers+1;
    system ("cls");
    cout << "\tMAIN MENU\n\n";
    cout << "\n\n";
    cout << "Press 1 to play\n";
    cout << "\n\n"; // main menu
    cout << "Press 2 to read instructions\n";
    cout << "\n\n";
    cout << "Press 3 to quit\n";
    cout << "\n\n";
    cin >> choice;

    switch (choice) {

    case 1:
    system ("cls");
    cout << "Please enter your first name: " << endl;
    cout << "\n\n";
    cin >> pname;
    system ("cls");
    cout << "Welcome " << pname;
    cout << "\n\n"; // brgining of game
    cout << "\n\n";
    printf("Please Enter a choice...\n");
    cout << "\n\n";
    printf ("Press 4 to explore your surroundings\n");
    cout << "\n\n";
    printf("Press 5 to attack\n");
    cout << "\n\n";
    cout << "Your Selection: " << endl;
    cin >> selecta;

    switch (selecta) {

    case 4:
    system ("cls");
    cout << "As you explore, you find a small knife." << endl;
    weapons=weapons+1;

    //old program code may or may not contain errors
    //after this point

    break;

    case 5:
    system ("cls");
    cout << "Theres Nothing to attack!!\n" << endl;
    break;

    case 2:
    system ("cls"); // instructions
    cout << "\tINSTRUCTIONS" << endl;
    cout << "\n\n";
    cout << "To Play Kimberly's Quest it could not be easier!\n" << endl;
    cout << "Just press the keys that are displayed on the screen\n" << endl;
    cout << "that correspond to the functions that need to be used.\n" << endl;
    cout << "In battle, you will given a different sort of menu,\n" << endl;
    cout << "but the means are the same.\n" << endl;
    cout << "BEST OF LUCK!\n" << endl;
    cout << "\n\n";
    break;

    case 3:

    cout << "See you soon!\n" << endl;
    break;
    // quit game or user wrong choice
    default:
    cout << "Incorrect Choice!\n" << endl;
    break;
    {
    system ("pause");
    {
    [\code]

  5. #5
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    [sarc] are you pulling my leg or something [sarc/]

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    1,200
    Tips for further posts: use the preview button.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  7. #7
    0x01
    Join Date
    Sep 2001
    Posts
    88
    Code:
    C or C++?. 'printf's' are mixed with 'cout's'; all of your variables are declared above main().  Can you not decide?
    
    Change all of your printf's to cout's.
    {
    	End your cout's with 
                                     << endl; 
                                     << ends;
                                     << flush;
    }
    
    Declare your variables when you need them.
    {
    	C++ offers this. Its convienent and your code becomes easier to read.
    	Esp. with large, complex programs.
    }
    
    Place brackets within your switch statments.
    {
    	For example,
    
    	case 1:
    		{
    			// ...
    			break;
    		}
    	default:
    		{
    			// if all else fails
    		}
    
    	Your code would become much easier to read.
    	You would have found your problem earlier.
    }
    
    /// misc
    
    Why are you using a switch() for 'choice'?
    {
    	If there is only 1 possible "case" for 'choice',
    	then why not just use if,else?
    
    	if (choice)
    	{
    		// ...
    	}
    	else
    	{
    		// ...
    	}
    }
    
    Fix
    {
    	I don't see an ending } for switch(selecta){ ...?
    	Where is your "return 0;" ?
    
    	//
    
    	Was switch (selecta) meant to be within switch (choice)?
    }
    
    Skipping chapters?
    Last edited by knave; 04-29-2005 at 07:46 AM.

  8. #8
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Welcome to the boards. If you haven't already done so then please take some time to familiarise yourself with the faq:
    http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

    Make sure you have a look at the the posting guidelines:
    http://cboard.cprogramming.com/annou...ouncementid=51
    Following the rules will ensure you get a prompt answer to your question.

    Remember, too, that the board has a search facility, a link is at the top of your screen:
    http://cboard.cprogramming.com/search.php
    It will often get you a quicker answer to your questions than waiting for a response to one you have posted.


    If you have any questions about this you may ask or you can contact one of our forum leaders:

    http://cboard.cprogramming.com/showgroups.php

    -----

    »Tips for further posts: use the preview button.
    and use the 'edit' button
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  9. #9
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Make sure you have a look at the the posting guidelines:
    When have you ever followed them? You're abusive and you post homework solutions. If they haven't kicked you off the boards, then they won't kick anyone.

  10. #10
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by 7stud
    When have you ever followed them? You're abusive and you post homework solutions. If they haven't kicked you off the boards, then they won't kick anyone.
    [clipped]

    this is me holding my tounge, and reconsidering my choice to start posting on the programming boards again.
    Last edited by major_small; 04-29-2005 at 08:08 AM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  11. #11
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,490
    fireman salem hoses down the flames.
    If the OP want's to start a new thread using [code][/code] tags, then they're free to do so.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

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