使用以下控制檯應用程序我將每個字符串轉換爲大寫字母。但是輸出中的字符串值保持不變。我在這裏做錯了什麼。任何有關這樣做的幫助,將不勝感激。謝謝你的幫助。將字符串轉換爲大寫字母有問題
int main()
{
vector<string> svec, svec_out;
string word;
int run;
cout << "Press 0 to quit giving input string" << endl;
while(1)
{
cin >> word;
svec.push_back(word);
cin >> run;
if (!run)
break;
}
cout << "converting to upper case... " << endl;
int i;
for (i = 0; i!=svec.size(); ++i)
{
word = svec[i];
for (string::size_type j=0; j < word.size(); ++j)
{
toupper(word[j]);
}
svec_out.push_back(word);
}
for (i = 0; i<svec_out.size(); i++)
cout << svec_out[i] << endl;
return 0;
}
那麼你應該接受的答案是幫助你(或者這個,如果你是由你自己完成的話)。 – Johnsyweb 2011-03-23 17:18:54
@Johnsyweb:作爲新的stackoverflow我仍然在學習它的功能。感謝您指向我:) – lycon 2011-03-23 17:53:41
你非常歡迎來到StackOverflow! – Johnsyweb 2011-03-23 20:37:50