C++ tutorial for beginners in telugu
The endl function ends the current line and starts a new line. In that way, it is much like the ‘n’ character. However, endl also flushes the output stream. When outputting text to a screen or a file in C++, data is fed into an output stream connected to the file or screen. Just because the data is in the stream, you cannot guarantee it has been written to the screen or the file. The endl function is one way to guarantee the text in that stream has been flushed.
The varying line-ending characters don’t matter, assuming the file is open in text mode, which is what you get unless you ask for binary. The compiled program will write out the correct thing for the system compiled for.
The only difference is that std::endl flushes the output buffer, and ‘n’ doesn’t. If you don’t want the buffer flushed frequently, use ‘n’. If you do (for example, if you want to get all the output, and the program is unstable), use std::end
The difference between variables and constants is that variables can change their value at any time but constants can never change their value. (The constants value is locked for the duration of the program.)
Constants can be very useful, PI for instance is a good example to declare as a constant.
Defining a constants
With the pre-processor directive “define” it is possible to define your own constants.
The format of the pre-processor directive #define is:
Escape codes are used to represent characters that are difficult to express otherwise in the source code.
For instance a tab (t). Escape codes all start with a backslash ().
|’||single quote (‘)|
|”||double quote (“)|
|?||question mark (?)|