ものづくりのブログ

うちのネコを題材にしたものづくりができたらいいなと思っていろいろ奮闘してます。

【C】Hello World を表示する

Ubuntu でC言語の開発準備を行いました。

コンパイラ

C言語用のコンパイラである gcc があるか確認します。

$ which gcc
/usr/bin/gcc

バージョンも確認します。

$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Hello World 表示

コード

Hello World を表示するコードを作成します。

#include <stdio.h>

int main(void)
{
    printf("Hello world !\n");

    return 0;
}

コンパイル

e$ gcc -o hello hello.c

実行

$ ./hello 
Hello world !