cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
user name:
password:
Forgot your password?
please wait
try again
cancel
forgot your password?
sign up
log in
[Legacy version]
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
c++ pointers
c++ pointers
Feb 26, 2016 at 2:29am
Feb 26, 2016 at 2:29am UTC
iamharshit
(3)
why my program crashes,if i do this?
int *p;
*p=2;
cout<<p<<endl;
Feb 26, 2016 at 2:42am
Feb 26, 2016 at 2:42am UTC
Chervil
(7320)
A pointer needs to point to
something
.
p is not initialised, it contains garbage.
That's ok until you try to modify the value pointed to, it is changing some random memory not owned by your program.
Topic archived. No new replies allowed.