cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
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 UTC
iamharshit
(3)
why my program crashes,if i do this?
int *p;
*p=2;
cout<<p<<endl;
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.