Skip to content

Instantly share code, notes, and snippets.

@masazdream
Created August 13, 2013 10:56
Show Gist options
  • Select an option

  • Save masazdream/6220056 to your computer and use it in GitHub Desktop.

Select an option

Save masazdream/6220056 to your computer and use it in GitHub Desktop.
stringはそもそもchar配列ということを理解するプログラム。
string line2;
cout << "何か数字を入力してください> " << flush;
getline(cin, line2);
cout << line2 << endl;
const char* line_array = line2.c_str();
const int size = line2.size();
cout << "文字列配列の長さ: " << size << endl;
for(int i = 0; i < size; ++i){
unsigned char c = (unsigned char)line_array[i];
cout << c << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment