We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi everyone,
How can I break a long instruction line into two or three lines to improve readability of the program written in " C language ?
Best regards, Deepak
if you need to break a C statement into many lines, I would hate to read your C.
I know that "real C" is the attempt to write the entire program in one statement, but IMHO it STINKS.
for example
for ( .. ; a,b,c,d ; ...) is difficult to read and almost impossible to comment in a sesible fashion
can be so much more readable (and compiles more compact) if written for ( ... ; a ; ....) { ... if (b) break; // comment ... if (c) break; // comment ... if (d) break; // comment ... }
Erik
"if you need to break a C statement into many lines, I would hate to read your C."
Not necessarily.
For example, an if statement is a single statement (possibly including an else clause) - but it is very common indeed to split it over many lines!
Another example: a function call is a single statement:
func( a, b, c );
but it can be quite helpful to split it over several lines:
func ( a, // document the 1st parameter b, /* document the 2nd parameter */ c // document the 3rd parameter );
Hi Everyone,
Thank you very much for the help provided and for the faq link. My issue was only the readability problem. We have a 80 column limit here! That was sorted by Mr. Andy Neil's first mail. Thank you all so much for helping me.
Multi Line macro was a new information for me. I never used macros!!
Thanks for the for(... a, b, ...) example by Mr. Erik.
absolutely 'reasonable' to split lines, that intention of my post was not to argue that point. However the most frequent reason for line splittiing is the so called "real C programmers" LOVE of cramming as much into one statement as possible, and THAT was what I really stated about.
"if you heard what I thought I said, we would communicate well" :)
"We have a 80 column limit here!"
Why?
Are you still coding on 80x24 terminals?
No sir, when we take print outs of the whole code for documentation in A4 paper it looks nice if it is a 80 column. thats all best regards, Deepak.
have not heard of that for ages
"we take print outs of the whole code for documentation in A4 paper"
What??
Everyone knows that Proper Listings have to be done on 132-Column fanfold paper... ;-)
Everyone knows that Proper Listings have to be done on 132-Column fanfold paper
just for your amusement
The Danish name for fanfold paper is "Leporello paper" I know why, anyone else?
www.isle-of-man.com/.../albums.htm ?
getting accustomed to your frequency,
say on
when asked, a simple redirection to other chips,
say on, what goes ahead,
is that another 'ghost'? It does not sound like Dan
Y a you guessed it right, eric,