I have written the following function:
void check(int* input){
do{
std::cout<<"Enter integer!";
std::cin>>*input;
}while(!std::cin);
}
And I am using it in the main function as follows:
int main()
{
int *k;
k=new int;
check(k);
std::cout<<"Value of the k is:"<<*k<<"in address"<<k;
return 0;
}
The problem is when user input some characters, the compiler keep printing "Enter integer!", non-stop, and I have to stop the compiler manually.
main? Why use pointers at all? Why not simple references?