C言語のハローワールドプログラム Code 例:
⚡ スマートサマリー
C言語の「Hello World」プログラムは、プリプロセッサディレクティブ、main関数、printf文など、C言語プログラムの基本的な構造を紹介します。画面にメッセージを表示し、C言語コードのコンパイルと実行方法を示します。

CのHelloWorldプログラム
これは C の Hello World プログラムです。
#include<stdio.h> // Pre-processor commands void main() { printf("Hello World\n"); // Print Hello World on the screen }
コードの説明は次のとおりです。
プリプロセッサディレクティブ
#include is a pre-processor directive in 'C.'
#include、stdio は関数が含まれるライブラリです。 printf printf は定義されています。printf は出力を生成するために使用されます。この関数を使用する前に、まず必要なファイル、つまりヘッダーファイル (.h) を含める必要があります。
独自の関数を作成し、それらをヘッダー ファイルにグループ化し、プログラムの先頭で宣言して使用することもできます。 プログラムにファイルを含めるには、プリプロセッサ ディレクティブを使用します
#include <file-name>.h
ファイル名は、関数が格納されているファイルの名前です。 プリプロセッサ ディレクティブは常にプログラムの先頭に配置されます。
主な機能
The main function is a part of every 'C' program. We can represent the main function in various forms, such as:
- メイン()
- int main()
- void main()
- メイン(ボイド)
- 無効メイン(ボイド)
- int main(void)
空の括弧は、この関数が引数、値、またはパラメータを取らないことを示します。括弧内にキーワード void を配置することで、これを明示的に表すこともできます。
#include<stdio.h> // Pre-processor directive int main() // main function declaration { printf("Hello World"); // to output the string on a display return 0; // terminating function }
上記の例では、キーワード int は関数が整数値を返すことを意味します。 この場合、最後のステートメントは常に 0 を返す必要があります。
ソースコード
main 関数を宣言した後、開き括弧と閉じ括弧を指定する必要があります。 中括弧 { }, プログラムの開始と終了を示します。これらの括弧は常に main 関数の後に置く必要があります。宣言部分や実行部分など、すべてのプログラム コードはこれらの括弧内に記述されます。
その printf function generates the output by passing the text "Hello World!"
その セミコロン ; ステートメントの終わりを決定します。 C では、各ステートメントはセミコロンで終わる必要があります。
したがって、正常にインストールされました コンパイラ and now can begin working in 'C.' We will write a simple program that will say hello to us. Let's start.
Cプログラムの実行方法
ステップ1) 新しいプロジェクトを作成する
ステップ2) ポップアップで、
- ファイルを選ぶ
- Choose the "C/C++ ソース"
- Click "Go."
ステップ3) Continue, by clicking on "Next."
ステップ4) To create the new file, select a "C" file then click on "Next" button to continue.
ステップ5) Set the file path by clicking the "..." button, the explorer window permits to create the C file.
ステップ6) 新しい C ファイルのパスを選択し、拡張子 .c が付いた名前を選択して保存します。
ステップ7) Finally, to confirm the C file creation click "Finish."
ステップ8) Enter the code, save it and compile it by clicking on the "Build & Run "button.
結果は次のとおりです。
Hello, World!








