• Advertisement
Sign in to follow this  

Whitespace

This topic is 4215 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been told 2 things about whitespace in a program: 1. Whitespace serves only to make your program more easy to read and has no effect on your program 2. Whitespace DOES have an effect on your program Which is true?

Share this post


Link to post
Share on other sites
Advertisement
Depends which language. Python, for example, relies heavily on whitespace to determine scope. C++, on the other hand, does not use it at all (except for rare cases).

Share this post


Link to post
Share on other sites
Whitespace serves only to make your program more easy to read and has no effect on your program. The only time it should have an effect on your program is if you have it within quotes, " ", in C++ of course, and C.

Share this post


Link to post
Share on other sites
Most whitespace has no effect on your program in most languages. The most common case in C-style syntaxes is something like >> vs. > > .

Share this post


Link to post
Share on other sites
In C or C++ neither whitespace nor comments have an effect on the compiled program.

Whitespace is defined as the space between function names, arguments, types, keywords, class names, operators or any other identifiers. Wherever a single space is valid, many spaces or line breaks will also be valid.

*edit: and as the above poster mentioned, you require at least one space between each identifier.

Share this post


Link to post
Share on other sites
Indeed, thanks all for your comments

Just figured I'd double check that before I went and did anything stupid with my coding skills.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement