I am not sure what the issue is with my code. I would like for the character to be updated and inserted into the stringstream on each iteration of the for-loop and extracted to a string that I can later use to append to a char[] variable. The output I wish to receive for the variable content is: What does CPU stand for? A. Central Processing Unit B. Control Programming Unit C. Central Proramming Unit D. Control Processing Unit Instead I get all A's down the line. How do I update the value in the stream so that temp takes on the values "A.", "B.", "C.", and "D.". I am not new to C++ but I am new to using stringstream. Can anyone explain what is happening and how I may be able to work around it? I am using a g++ compiler in a Unix environment.
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;