In the book called gnu c manual I read that the following code has an undefined behaviori=++i +1
; Because since the variable i is modified more than once between the sequence point,it is not sure that what value will 'i' have..But it is evident that the final value in 'i'(if i=1) would be 3..Can someone please clear my doubt..
saurabh.mehta.33234
13
Junior Poster in Training
ambreen.altafhussain
commented:
i=++i+1 shows pre and post both increments and answer will be 3 if i=1.
+0
Recommended Answers
Jump to PostIn the book called gnu c manual I read that the following code has an undefined behavior
i = ++i + 1;
Because since the variable i is modified more than once between the sequence point,it is not sure that what value will 'i' have.That's correct.
…
All 4 Replies
ambreen.altafhussain
0
Newbie Poster
saurabh.mehta.33234
13
Junior Poster in Training
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
saurabh.mehta.33234
13
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.