B.Li B.Li - 1 month ago 8
C Question

C styling: why assign variables with only one space?

My professor writes his C variable assignments like this:

int a= 10;

double t;
t= 0.5;

instead of

int a = 10;

double t;
t = 0.5;

He encouraged his students to do the same and mentioned that there was a specific reason as to why he does that, but never explained it.
Is it a preprocessing thing? I see no particular reason why writing it without the first space is better.


You can code in any styles. But you should adhere with K&R style i.e. a = 1; It will improve readability when working with you colleagues.