LoginSignup
1
0

More than 1 year has passed since last update.

【C++】基礎を学ぶ①~Hello Worldを理解する~

Last updated at Posted at 2022-07-05

はじめに

本記事ではC++でHelloWorldを出力するプログラムを解説する

HelloWorldを出力するプログラム

#include <iostream>

int main(){
  std::cout << "HelloWorld" << std::endl;
  return 0;
}

#include <iostream>とは

外部の装置と入出力を行う機能(ライブラリ)を追加している
プログラムを作るうえで絶対に必要になる

#include

○○を取り込むという意味
右側にあるファイルを読み込む

<iostream>

外部の装置と入出力を行う装置
input output streamの略

std::cout << "HelloWorld" << std::endl;とは

HelloWorldという文字列を出力して改行するプログラム

std::cout

名前空間stdcoutオブジェクト
標準出力に対応するオブジェクト
coutcharacter outputの略

std::endl

名前空間stdendl関数
改行文字を出力してバッファをフラッシュ
endlend lineの略

名前空間

重複を防ぐための仕組み
変数・関数・クラスが存在する住所を定義

int main()とは

1番最初に実行される関数
プログラムを作るうえで絶対に必要になる

関数の構文

終了時に返す値 関数の名前 (外部から投入する値){
  具体的な処理
}

次の記事

【C++】基礎を学ぶ②~文字列・数値を出力する~

1
0
3

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
1
0