new to c++, have an error i cannot figure out?

alrite i just started learning c++ 3 days ago and i decided to see what i cud put together with the knowledge ive gained so far. so i made a game, nothing complex by any means, but its a guessing game, i didnt come up with the idea, i just wanted to see if i cud figure out how to do it. so i entered in a code fixed all the errors i could. got all the errors fixed except for the last 1, which i cannot seem to find the problem?
here is the code


#include<iostream>
#include<ctime>
using namespace std;

int main (void);
{
int iUser;
int iGuess = 0;
int iGuesses = 0;
int iNumber = 0;

srand(static_cast<unsigned int>(time(0) ) );
iNumber = rand()%1000+1;
cout << "Enter your name: " << endl;
cin >> iUser
cout << iUser << " Enter a number 1-1000" << endl << endl;
cin >> iGuess
if
{
(iGuess > || < iNumber)
cout << "You got it!!!"
iGuesses ++;
cout << "The number is: " << iNumber
<< endl;
cout << "You took " << iGuesses
<< endl;
}
if
{
(iGuess > iNumber)
cout << "Too high!!!" << endl;
cin >> iGuess
}
if
{
(iGuess < iNumber)
cout << "Too low!!!" << endl;
cin >> iGuess
}
system("PAUSE")
return 0;
}


the error is on line six with the opening curly bracket.
it says "line 6 - expected unqualified-id before '{' token",
and "line 6 - expected ',' or ';' before '{' token"
i dont know if this is just a stupid mistake and im just missing something but ive been over it 100 times and cant seem to find a problem with that bracket or anything else?
any help would be greatly appreciated
thnx
closed account (z05DSL3A)
remove the ; from int main (void);

Edit:
There are a few other errors in your code, try:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>
#include<ctime>
using namespace std;

int main (void)
{
    int iUser;
    int iGuess = 0;
    int iGuesses = 0;
    int iNumber = 0;

    srand(static_cast<unsigned int>(time(0) ) );
    iNumber = rand()%1000+1;
    cout << "Enter your name: " << endl;
    cin >> iUser;
    cout << iUser << " Enter a number 1-1000" << endl << endl;
    cin >> iGuess;
    if(iGuess == iNumber)
    {
        cout << "You got it!!!";
        iGuesses ++;
        cout << "The number is: " << iNumber << endl;
        cout << "You took " << iGuesses << endl;
    }
    if(iGuess > iNumber)
    {
        cout << "Too high!!!" << endl;
        cin >> iGuess;
    }
    if(iGuess < iNumber)
    {
        cout << "Too low!!!" << endl;
        cin >> iGuess;
    }
    system("PAUSE");
    return 0;
}


How to: Put code into your postings
http://www.cplusplus.com/forum/articles/1624/
Last edited on
This is a double post of a thread, there's another (almost identical) one in the Beginners' forum (with very verbose answers :)

Maybe this one should be deleted?
Last edited on
Topic archived. No new replies allowed.