Hi guys
need a little help for my homework, any help is greatly appreciated.
:cheesy:
Qn 1. pointers
i have a problem with passing pointers to functions
code is as follows:
//function declaration
void computeProduct(product *pProduct,int *pBest);
//function call
computeProduct(product *pProduct,int *pBest);
//function definition
void computeProduct(product *pProduct,int *pBest)
{
//code
}
i keep gettin 2 errors when trying to compile:
a. expected primary expression before '*' token.
b. expected primary expression before "int".
both errors point to the function call.
any ideas/hints on what i'm doin wrong?
_________________________________________________________
Qn2. error checking
i need to error proof my program.
say i need to retrieve an integer input from user.
i need to make sure that the user inputs an integer or i will prompt him to re-enter value:
cout << "Enter integer value:";
cin >> test;
while (cin.fail())
{
cin.clear();
cin.ignore(1000,'n' );
cout << "Invalid entry, re-enter value:"
cin >> test;
}
yet, i'm unable to find a simple way to error proof the above user's input if it is of float type.
i.e. if user enters 2.3, the variable test will automatically be allocated the value 2.
any ideas how to ensure i can detect if user enters a float value?
thanks for any help in advance.
:cheesy: