Can someone tell me what's wrong with this Pointer code?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <cstring>

using namespace std;

int main(){
	int room;
	room = 12;
	int *roomPtr;
	*roomPtr = room;
	cout << "Address of room: " << &room << endl;
	cout << "Value of room: " << room << endl;
	cout << "Address of roomPtr: " << &roomPtr << endl;
	cout << "Value of roomptr: " << roomPtr << endl;
	cout << "Value pointed to: " << *roomPtr << endl;
	system("pause");
	return 0;

};
Last edited on
Should be : roomPtr = &room;
Topic archived. No new replies allowed.