MMGames Introduction to C C Language Development Environment C language now Useful Apps Contact Us

Automatic version identification


It's easy to tell by looking at it.

Response Time Checker

I can leave my computer on and do it.

Mouse cleaning time

I can leave my computer on and do it.

Mouse cleaning time

C language learned by suffering
C language learned by suffering

String display

absolutely necessary
We will now explain how to display strings on the screen.
That is because it is absolutely necessary for the various explanations that follow.

It's actually pretty easy to have a program do all sorts of things.
Making it understandable to humans is surprisingly difficult.
This is because the process inside a computer is nothing more than a flow of electrical signals.

Fortunately, however, it is now readily achievable.
Computers have displays.
Therefore, we can display the contents of the process on the display.

If the process is not displayed, learning programming is not possible.
The reason is that you don't know what the program did and what happened to it.

Therefore, for future programming studies, it is important to
You really need to learn how to display strings on the screen.
In other words, displaying strings on the screen is preparation for learning.
printf function
To print a string in C, use the printf function.
The printf function is used in the following manner.

source code

For example, if you want to display HelloWorld, do the following

source code

If you write this statement in your program, HelloWorld will appear on the screen.

By the way, where exactly should this statement be written?

HelloWorld Program
HelloWorld appears in most introductory books.
In that sense, it is probably the most famous program in the world.

Where to write?
As explained in the previous section, the printf function can be used to display text on the screen.
However, as explained at the beginning, the C language begins with the main function.
In other words, the printf function alone is not enough; the main function is always required.

For now, let us recall the main function program we created at the beginning.

Source Code
 int main(void)
    return 0;

We have already explained that the C language starts with the main function.
I did not explain in what order the program runs within that function.

Within a function, they simply move in order, starting with the statement above.
Then, when the return statement is reached, the function execution ends there.

For example, suppose you had a program like the following

source code
 int main(void)
    Statement 1;
    statement 2;
    return 0;
    statement 3;

The program runs in the order statement 1-> statement 2, and so on.
Statement 3 is ignored because the function ends with a return statement before reaching statement 3.

Given this, we can see where the printf function should be written.
In other words, you can write the following.

source code
 int main(void)
    return 0;

Importing Instructions
In the previous section, the program using the printf function should have been completed.
In fact, the program is not ready, so no text is displayed on the screen when it is run.
Some meddling compilers will get it to work...

Actually, the printf function is not a function of the C language itself.
In other words, the C compiler does not know anything about the function printf at all.
Therefore, simply writing a printf function will not work.
To make it work, you must have the compiler read the documentation for the printf function.

The C language provides special instructions for passing instructions.
It is the #include pseudo instruction.
The #include pseudo instruction can be used as follows

pseudo instruction
A pseudo instruction is an instruction that is not program code.
Since #include is an instruction that prepares the printf function, etc.
This instruction is not translated into machine language, but is processed at a preliminary stage.

source code
 #include <file name in instructions>.

The documentation for the printf function is a file called stdio.h.
In other words, you can use the printf function by adding the following program.

Source Code
 #include <stdio.h>

By the way, where should I write this order?
Since you are passing the program instructions, it must be before the program is executed.
After the program has been executed, it is too late to give the instructions.

Considering this, it would seem to be a good idea to write it at the beginning of the first line (before the main function).
In other words, a program that displays a string on the screen with the printf function would look like this

Source Code
 #include <stdio.h>

int main(void)
    return 0;

Note that #include is a pseudo instruction, so it can be written outside of a function.
Thank you for waiting
Thank you all for your patience.
Now we finally have a program that displays strings on the screen.

source code
 #include <stdio.h>

int main(void)
    return 0;

The result of executing this program is as follows

Execution Result

Policy for bitter C
In a typical introductory C book, you'd have to skip all the explanations from chapter 1 to this point to get to the
In many cases, the above program is introduced out of the blue, and
#include seems to put off the explanation, assuming it is a spell.
It is said that explaining unnecessary things at the beginning can be confusing.
I'm not sure which policy is correct.
As the author, I would like to follow the policy of explaining as much as possible.

About this Site

The C language (bitter C), which is learned by suffering, is
This is the definitive C language introductory site.
It systematically explains the basic functions of the C language and
It is as complete as or better than any book on the market.

Part 0: Program Overview
  1. What is the program?
Chapter 2: How to write a program
  1. Writing Rules
  2. Writing conventions
  3. Exercise 2
Chapter 3: Display on Screen
  1. String display
  2. newline character
  3. Exercise 3
Chapter 4: Numeric Display and Calculation
  1. Numeric Display
  2. Basic Calculations
  3. Type of value
  4. Exercise 4
Chapter 5: Numerical Memory and Calculation
  1. Memorize values
  2. Variable Type
  3. Type conversion
  4. Numeric justification
  5. Exercise 5
Chapter 6: Input from the keyboard
  1. Functions for input
  2. Fear of Input
  3. Exercise 6
Chapter 9: Repetition with a fixed number of times
  1. Sentences that repeat themselves
  2. Loop Operation Mechanism
  3. Exercise 9
Chapter 10: Unknown number of repetitions
  1. Loop of unknown frequency
  2. input check
  3. Exercise 10
Chapter 13: Handling Multiple Variables at Once
  1. Multiple variables are handled together.
  2. How to use arrays
  3. Exercise 13
Chapter 19: Dynamic Arrays
  1. Create arrays at will
  2. Exercise 19
Chapter 20: Multiple Source Files
  1. Minimal division
  2. The Stone of Division
  3. Exercise 20


Open the 💬 comment submission box