+ 1
Pre and Post Incrementsin C
Please look at this code and let me know what needs to be changed. It will hopefully be a helpful tutorial one day. https://pastebin.com/YJYayynP https://code.sololearn.com/c2PvOa75J4je Idea is to start building some help files to assist with the lessons.
3 odpowiedzi
+ 2
William Owens it is nice and comprehensive. I feel it is tedious to read through so many loop iterations. What matters most is the initial and final output values. The message gets lost in so many intermediate lines. Iterations could be reduced and still get the point across.
It appears that you struggled with embedding double quotes in the output. Precede a double quote with a backslash. So in places where you have this line:
puts("\tprintf("", ++counter);\n");
Replace it with this:
puts("\tprintf(\"%d\", ++counter);\n");
There is a missing closing parenthesis in the output string of line 31. I think the alternative increment options should be enclosed in < > instead of parentheses.
Review other output strings which show single quotes where they should show double quotes, and replace them with \".
+ 2
Brian, Thank you for the input. Ill make some adjustments.
+ 2
This is indeed a lot of information to take in. And confusing as well. The first two examples appear to demonstrate that preincrement uses the value and then increments, postincrement seems to first increment then use the value. I.e., precisely the opposite of what you want to express. Your conclusions then were not mine and then you can argue anything. If it does not match my observation, I am not going to understand.
I wonder if an allegorical depiction will have more of an effect. And perhaps a short memorable line.
Or to actually explain what happens. On a low level. It seems to me that the abstract "first value is used then it gets incremented" and the like are difficult to handle. To accompany those with further inside views of the CPU might make it understandable. I think that many have walked the path you're on already. And all have failed. At least on this platform (for more than one reason). But I am just fishing :)