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
Why is dangerous to run this?
Why is dangerous to run this?
May 23, 2013 at 9:54pm UTC
lucratico15
(6)
I have an exam tomorrow and one of the question from the review is to explain it is dangerous to run a program with this part of the code and what could happen?
1
2
char
*myPtr; *(myPtr + 2) =
'0'
;
May 23, 2013 at 10:07pm UTC
vlad from moscow
(6539)
myPtr has undefined value because it was not initialized or assigned. So the code
*(myPtr + 2) = '0';
has undefined behaviour. Where character '0' will be written?
May 23, 2013 at 10:32pm UTC
lucratico15
(6)
Thanks
Topic archived. No new replies allowed.