C++基本中の基本その3
※自分用メモ
※引用元「ローベルのC++入門講座」
【入力】
cin >> variable
でプログラムへと値を入力する。
#include <iostream> using namespace std; int main() { int a; cout << "your number is: " << flush; cin >> a; cout << "the total of "your number" and 100 is: " << a + 100 << "." << endl; return 0; }
結果
your number is: 32 the total of "your number" and 100 is: 132.
cin
の場合はcout
のときと違い>>
を使う。