do you like my c++ game

gordonm

New Member
Messages
6
Reaction score
0
Points
0
my very first game!

here is the source
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
//unknown
int MyGuess(0);
int Bob(1234);
//another integer

srand(time(NULL));
//guess = rand()%10+1;
cout << "enter a pin number for the info\n";
cin >> MyGuess;
//we tell the user the results
if(MyGuess == Bob){//check if myguess is guess
cout << "my password is blank\n";
} else {//otherwise
cout << "wrong ,try again!!!\n";
cout << "you guessed " << MyGuess << " and you fail! here is what you should have got ";
cout << Bob << "\n";
}
system("PAUSE");
return EXIT_SUCCESS;
}

i just posted this for the crack!:happysad:
 

daman371

New Member
Messages
130
Reaction score
0
Points
0
I'm not so sure it actually works. I don't know what Bob is being set to.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Code:
    int MyGuess(0);
    int Bob(1234);

The preferred form is:
Code:
    int MyGuess = 0;
    int Bob = 1234;

Code:
    srand(time(NULL));
    //guess = rand()%10+1;
The game would be a little harder if you uncommented this line and changed "guess" to "Bob".

Code:
           cout << "wrong ,try again!!!\n";
           cout << "you guessed " << MyGuess << " and you fail! here is what you should have got ";
           cout <<  Bob << "\n";

No need to repeat yourself.
Code:
           cout << "wrong ,try again!!!\n"
                   << "you guessed " << MyGuess << " and you fail! here is what you should have got "
                   <<  Bob << "\n";

Code:
    system("PAUSE");
You windows junkie. Just make sure you don't use system("PAUSE") for anything but the most trivial programs that are just for yourself. If anyone else is involved, use cin.ignore().
 

gordonm

New Member
Messages
6
Reaction score
0
Points
0
The preferred form is:
Code:
    int MyGuess = 0;
    int Bob = 1234;


The game would be a little harder if you uncommented this line and changed "guess" to "Bob".



No need to repeat yourself.
Code:
           cout << "wrong ,try again!!!\n"
                   << "you guessed " << MyGuess << " and you fail! here is what you should have got "
                   <<  Bob << "\n";


You windows junkie. Just make sure you don't use system("PAUSE") for anything but the most trivial programs that are just for yourself. If anyone else is involved, use cin.ignore().

can you help me with my cpp im a verry dumb beginer!
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
The C languages are not an easy place to start, don't get too down on yourself. You'll probably be learning something new every time you program, even 5 years from now. This is a decent tutorial: http://www.cplusplus.com/doc/tutorial/

I'd recommend downloading Visual C++ Express Edition 2008 from Microsoft. It's free and it will help you tremendously. http://www.microsoft.com/express/download/
 

daman371

New Member
Messages
130
Reaction score
0
Points
0
I've never seen that assignment for a variable before. I've taken 2 C++ courses in college. It's not too hard to pick up on. I mostly do stuff in PHP though, even though, in essence they are very similar. I do C++ programs for stuff I want to do locally and want to run quickly. Mainly Math programs.
 

idontkno

New Member
Messages
49
Reaction score
0
Points
0
The preferred form is:
Code:
    int MyGuess = 0;
    int Bob = 1234;
The game would be a little harder if you uncommented this line and changed "guess" to "Bob".



No need to repeat yourself.
Code:
           cout << "wrong ,try again!!!\n"
                   << "you guessed " << MyGuess << " and you fail! here is what you should have got "
                   <<  Bob << "\n";
You windows junkie. Just make sure you don't use system("PAUSE") for anything but the most trivial programs that are just for yourself. If anyone else is involved, use cin.ignore().

cin.get() works as well for him in this case.
 

gordonm

New Member
Messages
6
Reaction score
0
Points
0
hello all repliers ! !!!! thanks for all the help im going to make a revision of this in visual c++ as the other user suggested keep looking on this forum for an update whithin 2-4 days as im very busy with my current project
 
Top