LoginSignup
18
8

More than 5 years have passed since last update.

C++でHello World

Posted at

この記事の概要

ちょっと仕事で使う機会が出てきたので軽く触っておこうかと思い。

コンパイラのインストール

yumでインストール

$ sudo yum install gcc-c++

Hello worldを書いてみる

早速書いてみます。
・count、endlなどは「std」という名前空間にある
・stdは繰り返し使用するため「using namespace std;」と記述するのがお作法らしい

#include <iostream>

using namespace std;

int main(){
  cout << "Hello world." << endl;
  return 0;
}

コンパイル

g++の場合、下記コマンドでコンパイルできるようです。

$ g++ -o hello hello.cpp
$ ls
hello  hello.cpp

実行

$ ./hello 
Hello world.

できました!

18
8
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
8