使用以下控制台应用程序我将每个字符串转换为大写字母。但是输出中的字符串值保持不变。我在这里做错了什么。任何有关这样做的帮助,将不胜感激。谢谢你的帮助。将字符串转换为大写字母有问题
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