*Pointer program problem.
#include
using namespace std;
int main()
{
int age;
for (int i=0;i<5;i++)
{
cout << "Enter :";
cin >> age;
}
int *sum=&age;
for ( i=0;i<5;i++)
{
cout <<*(sum+i) << endl;
}
return 0;
}
here is one of my program that i wrote.
i do not know whats the problem with it.
it seems can't display back the values that i've entered in.
can sir/miss help me to correct my mistake(s).
Thank you!
koh
Junior Poster in Training
73 posts since Jul 2004
Reputation Points: 11
Solved Threads: 0
int age;
You haveage declared as a single int, but later try to operate on it as if it were an array of ints, which it is not.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
koh
Junior Poster in Training
73 posts since Jul 2004
Reputation Points: 11
Solved Threads: 0
6years too late and ignoring rules.
Thread closed
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 901