コードの問題が何であるかわかりません。forループの各反復で文字を更新して文字列ストリームに挿入し、後でchar[]変数に追加するために使用できる文字列に抽出したいと思います。可変コンテンツに対して受け取りたい出力は次のとおりです。CPUは何の略ですか。A.中央処理装置B.制御プログラミング装置C.中央処理装置D.制御処理装置代わりに、すべてのAを実行します。tempが値「A。」、「B。」、「C。」、および「D.」をとるように、ストリームの値を更新するにはどうすればよいですか。私はC++に不慣れではありませんが、stringstreamの使用には不慣れです。誰かが何が起こっているのか、そして私がそれをどのように回避できるのか説明できますか?Unix環境でg++コンパイラを使用しています。
char content[1096];
int numOfChoices;
char letterChoice = 'A';
string choice, temp;
stringstream ss;
strcpy ( content, "What does CPU stand for?");
cout << "How many multiple choice options are there? ";
cin >> numOfChoices;
cin.ignore(8, '\n');
for (int i = numOfChoices; i > 0; i--)
{
strcat (content, "\n");
ss << letterChoice << ".";
ss >> temp;
strcat(content, temp.c_str());
ss.str("");
cout << "Enter answer for multiple choice option "
<< letterChoice++ <<":\n--> ";
getline (cin, choice);
strcat(content, " ");
strcat(content, choice.c_str());
}
cout << content << endl;