- #1
beatlesben
- 4
- 0
Hello, I'm teaching myself C++. I'm pretty much at level one. Anyway I was trying to make a code, playing with pointers:
#include <iostream>
using namespace std;
int main()
{
int x;
int g;
int *p;
x = 1 + g;
cin>> g;
p = &x;
cin.ignore();
cout<< *p <<"\n";
cin.get();
return 1;
}
When I run the code it says that g is not defined, but g is what you have to enter, so I don't understand how to define it.
Also could someone explain "return." I don't understand what the value next to it means.
Thanks,
Remember, this is my second day of learning this...
#include <iostream>
using namespace std;
int main()
{
int x;
int g;
int *p;
x = 1 + g;
cin>> g;
p = &x;
cin.ignore();
cout<< *p <<"\n";
cin.get();
return 1;
}
When I run the code it says that g is not defined, but g is what you have to enter, so I don't understand how to define it.
Also could someone explain "return." I don't understand what the value next to it means.
Thanks,
Remember, this is my second day of learning this...