Hey, I've been playing around with C++ for a few weeks however I seem to be doing something wrong with pointers still.
Code:
#include <iostream>
#include <fstream>
using namespace std;
main(){
int age;
int *data;
*data &= age;
cout<<"How old are you?\n";
cin>>*data;
cin.get();
cout<<"you are " <<*data<< " years old!";
cin.get();
cout<<"I repeat you are " <<age<< " years old!!";
cin.get();
}
I wanted to see if it did actually store the data correctly in both the original integer and the pointer however it seems to only store the input in the pointer and the age simply displays a random big number. Could anyone 'point' me in the right direction here
Thanks.