I am taking a C++ class in school and was give a few lines of code with errors and I'm having trouble finding all 4 errors. The code is supposed to print the number "302" I'm not good with pointers. Here is the code
int main () {
int* ptr;
int* temp;
int x;
ptr = int;
*ptr = 3;
cout << ptr << endl;
x=0;
temp = x;
cout<<*temp<< endl;
ptr = int;
*ptr = 2;
cout<<*ptr-*temp <<endl;
return 0;
}
The two errors i have found so far are
- cout and endl need to have ::std in front of them
- temp = x needs to be a pointer, *temp = x