What's the purpose of adding spacings between operators?

c, c++, spacing

Solution

Sometimes space is necessary because the maximal munch priciple of the C/C++ lexer. Consider `x` and `y` are both pointers to int, expression

*x/*y

is illegal because the lexer will treat `/*` as comment. So in this case, a space is necessary:

*x / *y

(From book "Expert C Programming")

Problem

I basically learnt C/C++ programming by myself, so I don't know much about good programming habit. One thing always make me wonder is why people always like to add spacing between operators in their codes like: ``` if(x > 0) ``` instead of ``` if(x>0) ``` Are there any particular reasons for that? We know the compiler simply ignores such spacings, and I don't think the latter expression is less readable.

Original source