434,587 Members | 1,076 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

error calling of non function

 P: n/a i was asked to do game that are similar with mastermind game. but i have an error that my program said there is calling of non function. here is my code hope there is solution for this error. tq. #include #include //-----void main() void main() { void Header(); Header(); void GenRand(); GenRand(); getch(); } //-----end void main() //-----void Header() //display the header void Header() { cout << "===========Welcome to the Game==========" << endl; cout << "This is a game of logic." << endl; cout << "The goal is to guess the correct four symbols combination by using your previous guesses as clues." << endl; cout << "Everytime you guess,you will be told how close to the goal you are." << endl; cout << "The first number says how many symbols are in the right place." << endl; cout << "The second number says how many right symbols are in the wrong place." << endl; cout << "To guess, enter four symbols choosen from the set of five symbols." << endl; cout << "The five symbols are % # \$ * &" << endl; cout << "A sample guess would look like this: % * \$ #" << endl; cout << "You have 6 tries to complete the goal." << endl; cout << "All the best!" << endl << endl; } //-----end void header() //-----void GenRand() //generate random numbers void GenRand() { srand((unsigned)time(NULL)); int rand; for(int i = 0 ; i <4 ; i++) rand[i] = rand() % 5; while (rand == rand) rand = rand() % 5; while (rand == rand || rand == rand) rand = rand() % 5; while (rand == rand || rand == rand || rand == rand) rand = rand() % 5; void RandSym(int); RandSym(rand); } //-----end void GenRand() //----void RandSym() void RandSym(int rand) //associate the random numbers with symbols { char code; for (int i = 0 ; i <4 ; i++) { //conversion of rand1 to a symbol from a number if(rand[i] == 0) code[i] = '%'; else if (rand[i] == 1) code[i] = '#'; else if (rand[i] == 2) code[i] = '\$'; else if (rand[i] == 3) code[i] = '&'; else if (rand[i] == 4) code[i] = '*'; else; } for (int i=0 ; i<4 ; i++) cout <<""<> guess1 >> guess2 >> guess3 >> guess4; Check(code,guess1, guess2, guess3, guess4,right, wrong); if (guess1==code && guess2==code && guess3==code && guess4==code) { cout << " ********** " << endl; cout << "===============*YOU WIN!*===============" << endl; cout << " ********** " << endl << endl; goto end;} else { cout << " Right symbol & right position:" << right << endl; cout << " Right symbol & wrong position:" << wrong << endl; } } cout << "\nSORRY! Answer was: " <
3 Replies

 Expert 100+ P: 542 1: add 'use namespace std' before main function 2: in GenRand() function, change the name of rand array to some other name say my_rand. its conflicting with rand() call. 3: return type of main should be int. 4: In check() method, please put proper opening and closing bracket of conditional statements. Make these changes, post your code in [code] tags. Oct 13 '10 #2

 Expert 100+ P: 2,400 In the future, please post the full text of compiler error messages. Oct 13 '10 #3

 Expert 100+ P: 983 syakirah, Also, if you can enclose your code in [ code ] tags, it'll help a lot. When you don't, the code indentation is removed, which is very irritating. Good Luck! Oct 13 '10 #4 