There's this relatively common syndrome where code pasted into the question is double-spaced (with a blank line in between every line of text) -- see for instance the earliest revisions of https://stackoverflow.com/posts/5128613/revisions -- it seems to happen more often with new posters who haven't figured out how to format stuff yet, but I really doubt they're coding that way, so I wonder if there's a bug somewhere that causes DOS line endings to become extra blank lines when pasted into the question-edit box.
1 Answer
When I fetched original poster's source,
https://stackoverflow.com/revisions/1a0700d0-eaf6-421c-b9bf-2699755371b6/view-source
and I found that there is many \r\n\r\n
sequences there.
So I think that is not DOS issue, original texts is like that as is.
#include <iostream>\r\n\r\nusing namespace std;\r\n\r\nstruct list\r\n\r\n{\r\n\r\nchar name[20];\r\n\r\nint age;\r\n\r\ndouble height;\r\n\r\nlist *next;\r\n\r\n};\r\n\r\nlist *first = NULL, *current=NULL;\r\n\r\nint optn = 0;\r\n\r\nvoid currentfor()\r\n\r\n {\r\n\r\n if (current==NULL)\r\n\r\n {\r\n\r\n cout << "Current is invalid" <<.....
-
Hmm. The original poster commented "I tried putting the code without spaces but it looked so messed up in the preview.So wen i put spaces it came out decently in the coding format". So it looks like you're right and what we really need is to improve the UI for triggering code formatting.– zwolCommented Feb 26, 2011 at 18:39
-
I must be missing something here. There's a tool for marking something as code. It's on the line that begins with the "B for bold" tool. It looks like a pair of braces. I like the way it formats code just fine. Commented Feb 26, 2011 at 18:42
-
Select the raw code, and ctrl+k would be ok for code blocks normally, IHMO. I don't think SO will convert
\r\n
to\r\n\r\n
though.– YOUCommented Feb 26, 2011 at 18:50