Ummm, you have it all wrong, take this
Code:
int *p = new int;
*p = 5; // Now I change the value.
cout << *p << endl; // This will in my example print 5
cout << p << endl; // This will print the address p points to.
Now that was about the pointer.
So from that we can make out that in your code isdigit gets the value (isdigit(*ans)) and atoi gets the address which the pointer points to (atoi(ans))
Lets go on to the new thingy:
You can safely do this:
Code:
for(;;)
{
int i = 0;
// bla bla bla
}
Because i will go out of scope when the loop does another pass.
Last but not least, the cin-problem.
Code:
#include <iostream>
using namespace std;
int main()
{
int *p = new int;
cin >> p;
}
This gives me 22 errors with MingW which is one of the most standard-complaiant (sp?) compilers out there.
Code:
#include <iostream>
using namespace std;
int main()
{
int *p = new int;
cin >> *p;
}
This gives me 0 errors on the same compiler.