C++でプログラム書いてみるよ

  • 1️⃣C++でハロワ
  • 2️⃣C++でcout
  • 3️⃣streamってなんだろう
  • 4️⃣いろんなものを流しこもう
  • 5️⃣Cの文字
  • 6️⃣Cの文字列
  • 7️⃣C++の文字列
//ヘッダーファイル:関数やライブラリの宣言が入っている
#include <iostream> //標準入出力 stdio.h
#include <string> //文字列操作
 
//ソースファイル:関数やライブラリの定義が入っている
 
int main() //main関数:プログラムの開始地点
{
	//std::cout << "Hello World!" << std::endl; //標準出力
	int a = 10;
	float b = 3.14;
	double c = 3.14159265359;
	char d = 'C';//''シングルクォートでアスキーコード表を参照
	char str[] = "Hello World!";//""ダブルクォートで文字列
	std::string str2 = "Hello World!";//string型
	std::string str3 = "なのよん";
	std::string str4 = str2 + str3;//文字列の結合;
 
 
	std::cout << 6 << " " << 16 << " " << 26 << std::endl;
	std::cout << 7 << " " << 8 << " " << 9 << std::endl;
	std::cout << a << " " << b << " " << (int)c << std::endl;
	std::cout << "文字型:" << d << std::endl;
	std::cout << "文字列:" << str << std::endl;
	std::cout << "string型:" << str4 << std::endl;
 
	return 0; //0を返して終了
}
  • game-engineer/classes/2025/game-development-1/no-01.txt
  • 最終更新: 4カ月前
  • by root