- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Whitespace in C++
Whitespace is a term that refers to characters that are used for formatting purposes. In C++, this refers primarily to spaces, tabs, and (sometimes) newlines. The C++ compiler generally ignores whitespace, with a few minor exceptions. For example, all the 4 lines below mean the same thing −
cout<<"Hello"; cout << "Hello"; cout << "Hello" ; cout << "Hello";
The exceptions where C++ compiler takes whitespace in consideration is inside quotes and for operator detection. So whenever you put in a string, c++ takes note of the whitespace. For example,
"Hello world!" "Hello world!"
Both of these are different strings. Also when you use compound operators or any multi-character operator, you cannot put in space between. For example,
<< and < < are different. Similarly, += and + = are different, with the latter not being a valid expression.
Advertisements