473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

error calling of non function

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<iostream.h>
#include<conio.h>

//-----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[4];

for(int i = 0 ; i <4 ; i++)

rand[i] = rand() % 5;

while (rand[1] == rand[0])
rand[1] = rand() % 5;

while (rand[2] == rand[0] || rand[2] == rand[1])
rand[2] = rand() % 5;

while (rand[3] == rand[0] || rand[3] == rand[1] || rand[3] == rand[2])
rand[3] = rand() % 5;

void RandSym(int[4]);
RandSym(rand);


}
//-----end void GenRand()

//----void RandSym()
void RandSym(int rand[4])
//associate the random numbers with symbols
{
char code[4];

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 <<""<<code[i]<<"";

void Play(char [4]);
Play(code);

}
//-----end void RandSym()

//-----void Check()
void Check (char code[4], char guess1, char guess2, char guess3, char guess4, int &right,int &wrong)
//calculating right wrong
{
if (guess1==code[0] && guess2==code[1] && guess3==code[2] && guess4==code[3])
goto out;
//calculating for correct symbol and position and correct symbol but wrong position
else {

if (guess1 == code[0])
right++;
else
if ((guess1==code[1])||(guess1==code[2])||(guess1==code[3]))
wrong++;
else;

if (guess2 == code[1])
right++;
else
if ((guess2==code[0])||(guess2==code[2])||(guess2==code[3]))
wrong++;
else;

if(guess3 == code[2])
right++;
else
if ((guess3==code[0])||(guess3==code[1])||(guess3==code[3]))
wrong++;
else;

if (guess4 == code[3])
right++;
else
if((guess4==code[0])||(guess4==code[1])||(guess4==code[2]))
wrong++;
else; }
out:
}
//-----end void Check()

//-----void Play()
void Play(char code[4])
{
void Check (char [4], char, char , char , char , int&, int&);
char guess1, guess2, guess3, guess4;

for(int i=1;i<=6;i++)
{
int right=0;
int wrong=0;



cout<<"\n\nTRIAL :"<<i<<endl;
cout<< "Enter your guess with four symbols (%,#,$,&):";
cin >> guess1 >> guess2 >> guess3 >> guess4;


Check(code,guess1, guess2, guess3, guess4,right, wrong);

if (guess1==code[0] && guess2==code[1] && guess3==code[2] && guess4==code[3])
{
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: " <<endl;
for (int i = 0 ; i <4 ; i++)
cout << ""<<code[i]<<"" ;

end:



}
Oct 13 '10 #1
3 2009
ashitpro
542 Expert 512MB
1: add 'use namespace std' before main function
2: in GenRand() function, change the name of rand[4] array to some other name say my_rand[4]. 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
donbock
2,426 Expert 2GB
In the future, please post the full text of compiler error messages.
Oct 13 '10 #3
Oralloy
988 Expert 512MB
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

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Daniel Hansen | last post by:
I'm sure I saw this somewhere but can't remember where and can't find it now... Is there a PHP function or global variable that will return name of the calling function? I want to do this for...
1
by: Red Ogden | last post by:
The following script returns an error saying document.all is null or not an object when I try to call the write_layer function more than once within the same else statement i.e.: else {...
4
by: evan.cooch | last post by:
Greetings. Suppose I have some function called "CheckIt" - some function to validate form data before submitting it to e CGI script. Pretend the name of the form is "TheForm". If I use the...
2
by: flupke | last post by:
Hi, i have a property in a class that gets changed and i would want to know who changes it. Is there a way i can find out the calling function of a property? Thanks, Benedict
6
by: jchao123 | last post by:
Dear All, I have an MDB file (Access 2000/XP) which contains generic routines I use in various apps (eg, API calls, File access classes etc). I have compiled into an MDE file which I reference...
4
by: astri | last post by:
#include "Unit1.h" #include "math.h" #include "fixed_math.hpp" #include "algorithm.h" #define MBIT 0x4000 #define CBIT 16 long constbl; void __fastcall TForm1::Button1Click(TObject...
15
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
0
by: techie88 | last post by:
Hello I'm completely new to C++ and VB programming. I am working on a Visual Studio 6 application that passes values from VB to C++ methods using BSTR conversions. Within the C++ code I am...
2
by: sawaipurush | last post by:
I am trying to write an application that will detect all the USB devices connected to my computer. For this I have declared GUID and called the following functions to get the information about...
3
oranoos3000
by: oranoos3000 | last post by:
hi i want to get time of server with ajax,php,javascript i use under scritp and with method onload i get time on server and show on the page so i want in a period time the same function is run...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.