※スタイルシート未対応ブラウザではレイアウトを正確に再現できません。
  > | advanced by | contents  | that returns in <    
                   < [modosusu] > Color magazine monochrome light and shade   font predetermined, Gothic Ming-style type longhand   size Konaka large   standard  


  Line-feed character   

  1. ..clause 1..: Changing line problem
  2. ..clause 2..: Escape sequence

[1] Changing line problem

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?

 
#include <stdio.h> 

int main(void)  
{
	printf("Hello");  
	printf("world");  
	return 0;
}
The execution result was as follows.

Helloworld
I think that I notice one important thing when this is seen.
It is not to change line.

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 returns to contents.


[2] Escape sequence

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.


[   Escape sequence   ]
Special character used to do control that cannot be displayed on screen.
If you write it in the character string where the character called this \n is displayed
It changes line in the place with \n on the screen and it is displayed.

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.

 
#include <stdio.h> 

int main(void)  
{
	printf("Hello\n");  
	printf("world\n");  
	return 0;
}
The execution result of this program becomes as follows.

Hello
world
This line-feed character can use only a favorite number for a favorite position.
For instance, even if the program ahead is rewritten as follows, the result is the same.
 
#include <stdio.h> 

int main(void)  
{
	printf("Hello\nworld\n");  
	return 0;
}
There is \n in the center though it might be a little cramped.

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.

 
#include <stdio.h> 

int main(void)  
{
	printf("Windows\tMicrosoft\n");  
	printf("MacOS\tApple\n");  
	return 0;
}
The execution result of this program becomes as follows.

Windows Microsoft
MacOS   Apple
The head is arranged and the second character is displayed.

It returns to contents.


< - It is advanced -> | in | head that returns  to returning  next |.