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


  Display of character string   

  1. ..clause 1..: It is necessary by all means.
  2. ..clause 2..: Printf function
  3. ..clause 3..: Where does write?
  4. ..clause 4..: Taking of manual
  5. ..clause 5..: I'm sorry to have kept you waiting.

[1] It is necessary by all means.

Hereafter, it explains the method of displaying the character string on the screen.
It is because of needing it by all means to explain after this variously.

Though it is actually easy to make them do various processing by the program
It is unexpectedly difficult to make man understand it.
Because processing in the computer only flows an electric signal and exists.

However, it can be easily fortunately achieved now.
The display is attached to the computer.
Therefore, only have to display the content of processing on the display.

The study of the programming doesn't work out if the content of processing is not displayed.
It is because it is not understood what the program does and very it became it.

Therefore, for the programming study in the future
It is necessary to learn the method of displaying the character string on the screen by all means.
In a word, it is a preparation that displays the character string on the screen for study.

It returns to contents.


[2] Printf function

Use printf ([purintoefu]) function to display the character string by C language.
Use the printf function as follows.


printf("文字列");
For instance, do as follows when you want to make it display as Hello and world.

printf("Hello, world");
To the screen if you write this sentence in the program It is displayed as Hello and world.

By the way, where should be on earth written this sentence?


[  Hello,  ]
Hello and world appear in most introductions.
In that sense, it seems that it is the most famous program in the world.

It returns to contents.


[3] Where does write?

If the printf function is used as explained in the preceding clause, the character is displayed on the screen.
However, C language starts from the main function as explained in the start.
In a word, it is useless, and the main function is always necessary only in the printf function.

Recall the program of the main function made in the start for the time being.

 int main(void)  
{
	return 0;
}
Though it explained C language starts from the main function
It did not explain in what order the program moved in the function.

It moves sequentially from the sentence above simply in the function.
And, the execution of the function ends then when reaching the return sentence.

For instance, when assuming that there were the following programs

 int main(void) 
{
	Sentence 1;
	Sentence 2;
	return 0; 
	Sentence 3;
}
The program moves in order in which sentence one-sentence 2 of >.
Because the function ends by the return sentence before it reaches sentence 3, sentence 3 is disregarded.

The place where the printf function should be written is understood when thinking from this.
In a word, will only have to write as follows.

 int main(void)  
{
	printf("Hello, world");  
	return 0;
}

It returns to contents.


[4] Taking of manual

Though it is necessary to have completed the program that uses the printf function in the preceding clause
Actually, even if this program is moved because it is unprepared, the character is not displayed on the screen.
In the compiler that burns meddlesomeness though it moves ・・・

Actually, the printf function is not a function of C language.
The compiler of C language doesn't know the function named printf at all if it paraphrases it.
Therefore, it doesn't move only by describing the printf function.
It is necessary to read the manual of the printf function to operate the compiler.

A special instruction to pass the manual is prepared in C language.
It is # include (include) quasi-instruction.
#The include quasi-instruction can be used as follows.


[   Quasi-instruction   ]
The quasi-instruction is an instruction that is not the program code.
#Because include is an instruction that prepares the printf function etc.
This instruction is not translated into the machine language, and processed at the former stage.
 
#File name > of include < manual
The manual of the printf function is a file called stdio.h.
In a word, if the following programs are added, it comes to be able to use the printf function.
 
#include <stdio.h> 
By the way, where should be written this instruction?
It should be before the program is executed because the manual of the program is passed.
After the program has been executed, it is too late even if the manual is passed.

In view of this, you seem should write at the first head (From the main function ahead).
In a word, the program that displays the character string on the screen by the printf function is as follows.

 
#include <stdio.h> 

int main(void)  
{
	printf("Hello, world");  
	return 0;
}
Because # include is a quasi-instruction, it is possible to write outside of the function.

It returns to contents.


[5] I'm sorry to have kept you waiting.

..waiting.. [taseitashimashita] for a long time ..everybody...
Finally, the program that displayed the character string on the screen was completed by this.

 
#include <stdio.h> 

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

Hello, world

[ Policy of   worried C  ]
In the introduction of C language, all explanations from Chapter 1 to here must fly.
It often suddenly introduces the above-mentioned program.
#Include seems to assume that it is a charm and to postpone explaining.
Because it is said that it is confused if it explains an extra thing in the beginning
Though it doesn't understand which policy is correct
As the author, it wants to schedule it is possible to do to explain and to live.

It returns to contents.


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