2018-11-17から1日間の記事一覧

C++ / 範囲ベースforとauto型

#include <iostream> using namespace std; int main(){ char vals[] = {'a','b','c','d'}; int num = sizeof(vals)/sizeof(char); // 普通のforループ for(char i=0; i</iostream>

C++ / sizeof演算子

函数ではなく演算子なのでカッコでくくる必要はないがカッコでくくるのが慣例との由。 #include <iostream> using namespace std; int main(){ int a[] = {0,1,2,3,4,5}; cout << "int型排列aの全体のバイト数: " << sizeof(a) << endl; cout << "int型のバイト数: " <</iostream>…

C++ / stringクラス

#include <iostream> #include <string> using namespace std; int main(){ string sute = "これはテストです。"; cout << sute << endl; cout << "これは試験です。" << endl; char hoge[] = "これも試験です。"; cout << hoge << endl; system("pause"); return 0; }</string></iostream>