Thread: code help

  1. #16
    Registered User
    Join Date
    Mar 2003
    Posts
    176
    i did follow the setup instructions exactly and if you could tell me what i need to do to fix this error

    5 C:\Dev-Cpp\Untitled1.cpp
    parse error before `)' token

    i think it will work the code is

    #include <windows.h>

    main ()
    {
    ()cout << "Hello World!" << endl;

    ()cout << "Press ENTER to continue..." << endl;
    ()getchar ();
    return 0;
    }

  2. #17
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    i have never ever seen code with the () like that, i dont think its even c++ syntax honestly. Try putting those two files into your header directory and try my code again. Both the one with namespace and the one without.

  3. #18
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    the reason it is not working is because of the () before the cout and the getchar.

    just noticed, RoD beat me.

  4. #19
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    looked up a list of compilers for you:

    http://www.cpp-home.com/db/db.cgi?ui...records=Search

  5. #20
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    Code:
    extern "C" system(const char *);
    
    int main()
    {
    	system("echo Hello World!");
    	system("pause");
    
    	return 0;
    }
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  6. #21
    Registered User
    Join Date
    Mar 2003
    Posts
    176
    i got it to work there was something wrong with compiler i had to download the beta version i made improvements on an example game in there and i think i have a handle on this whole programing thing thing the next thing i am gonna do is gonna be like mad libs your gonna fill in the blanks then the story will pop up with all the words you pop in.( i just got this idea and haven't started to work on it yet) but i think it will be cool. also thanks for all the help. see ya

    if you want to play my game could someone post how i put files into these? thanks again and bye

  7. #22
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    put files? do you mean upload files to the board?

    if you do, there is an "Attach File" option under Options (no pun intended) and you can do it from there.

  8. #23
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    its right above submit....if you have trouble posting the files email them to me and i will gladly post them here for you.

    [email protected]

  9. #24
    Registered User
    Join Date
    Mar 2003
    Posts
    176
    ah ok i see it thanks ill e-mail it to you because it needs to be put into a zip file

  10. #25
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Can do. I'll check my mail in a few minutes.

  11. #26
    Registered User
    Join Date
    Mar 2003
    Posts
    176
    rod are you gonna post that game?

  12. #27
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    I would if it was in my inbox....what email did you send it from? I usually get email very quick...

  13. #28
    Registered User
    Join Date
    Mar 2003
    Posts
    176

    Talking

    ill just post the code then no one has to dl it lol

    #include <iostream>
    #include <stdlib.h>
    #include <time.h>

    using namespace std;

    void Start ();
    void GetResults ();

    int i, j, life, maxrand;
    char c;


    void
    Start ()
    {
    i = 0;
    j = 0;
    life = 0;
    maxrand = 6;

    cout << "Select difficulty mode:\n"; // the user has to select a difficutly level
    cout << "1 : Easy (0-15)\n";
    cout << "2 : Medium (0-30)\n";
    cout << "3 : Difficult (0-50)\n";
    cout << "or type another key to quit\n";
    c = 30;

    cin >> c; // read the user's choice
    cout << "\n";

    switch (c)
    {
    case '1' : maxrand = 15; // the random number will be between 0 and maxrand
    break;
    case '2' : maxrand = 30;
    break;
    case '3' : maxrand = 50;
    break;
    default : exit(0);
    break;
    }

    life = 10; // number of lifes of the player
    srand( (unsigned)time( NULL ) ); // init Rand() function
    j = rand() % maxrand; // j get a random value between 0 and maxrand

    GetResults();

    }


    void
    GetResults ()
    {
    if (life <= 0)
    // if player has no more life then he lose
    {
    cout << "HAHAHAHAHA YOU IDIOT YOU CANT EVE GUESSE A NUMBER RIGHT!!!!!!!!!!!!!!!\n\n";
    Start();
    }

    cout << "Type a number: \n";
    cin >> i; // read user's number

    if ((i>maxrand) || (i<0)) // if the user number isn't correct, restart
    {
    cout << "Error : Number not between 0 and \n" << maxrand;
    GetResults();
    }

    if (i == j)
    {
    cout << "you have just wasted one minute of your life but you win.\n\n"; // the user found the secret number
    Start();
    }

    else if (i>j)
    {
    cout << "Too BIG\n";
    life = life - 1; // -1 to the user's "life"
    cout << "Number of remaining life: " << life << "\n\n";
    GetResults();
    }

    else if (i<j)
    {
    cout << "Too SMALL\n";
    life = life - 1;
    cout << "Number of remaining life:\n" << life << "\n\n";
    GetResults();
    }
    }


    int
    main ()
    {
    cout << "** Jackpot game **\n";
    cout << "The goal of this game is to guess a number. You will be ask to type\n";
    cout << "a number (you have 5 guess)\n";
    cout << "Jackpot will then tell you if this number is too big of too small compared to the secret number to find\n\n";
    Start();
    return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM