In the foregoing paragraph, the character string was displayed on the screen by using the printf function.
If the printf function is used, the character string can be displayed on the screen very much.
By the way, how are you displayed when the following program is executed?
The execution result was as follows.#include <stdio.h> int main(void) { printf("Hello"); printf("world"); return 0; }
I think that I notice one important thing when this is seen.
Helloworld
With this, it can do nothing but single-mindedly arrange sideways, display, and be very inconvenient.
Though it changes line at the position as long as a right edge of the screen is displayed
Cannot they change line more freely?
It is not possible to change line to display the character string on the screen, it is too inconvenient.
Then, the function to make them change line to C language at a favorite position is prepared.
Use the escape sequence to change line by programming C language.
The escape sequence is a special character used to do the control that cannot be displayed on the screen.
There is \n in one of the escape sequences, and this is supposed to show changing line.
If you write it in the character string where the character called this \n is displayed
[ Escape sequence ]
Special character used to do control that cannot be displayed on screen.
Use not \(yen sign) but \(backing slash) sign in foreign countries.
This is because a part of font of a character of the personal computer of Japan and overseas personal computer is different.
However, the problem doesn't happen because both are internally treated as quite the same character.
The following program is an example of making them change line by using escape sequence \n.
The execution result of this program becomes as follows.#include <stdio.h> int main(void) { printf("Hello\n"); printf("world\n"); return 0; }
This line-feed character can use only a favorite number for a favorite position.
Hello
world
There is \n in the center though it might be a little cramped.#include <stdio.h> int main(void) { printf("Hello\nworld\n"); return 0; }
In many cases, because it becomes easy to see changing line whenever one line is displayed
It will change line without fail as long as especially groundlessly at the end of one line in the future.
The thing used is limited though other various escape sequences exist.
\t that inserts the tab for the head arrangement is often used excluding the line-feed character.
The following program is an example of doing the head arrangement with \t.
The execution result of this program becomes as follows.#include <stdio.h> int main(void) { printf("Windows\tMicrosoft\n"); printf("MacOS\tApple\n"); return 0; }
The head is arranged and the second character is displayed.
Windows Microsoft
MacOS Apple