【发布时间】:2020-01-19 19:26:31
【问题描述】:
我想知道如何使用 toupper 功能,以便用户可以以任何他们想要的方式输入这些单词。
//fill in arrays
word[0] = "VERY";
word[1] = "MERRY";
word[2] = "CHRISTMAS";
word[3] = "EVERYONE";
for (i= 0; i<4; i++)
{
word[i] = toupper(word[i]);
}
food[0] = "CANDY";
food[1] = "CAKE";
food[2] = "SOUP";
food[3] = "COOKIE";
for (j=0;j<4;j++)
{
food[j] = toupper(food[j]);
}
cout<<"\n Pick a word it can either be VERY, MERRY, CHRISTMAS, EVERYONE (can be written in anyway)";
cin>> word[i];
cout<<"\n Pick a food, it can be CAKE,SOUP, CANDY, OR COOKIE, can be written anyway)";
cin>> food[j];
还有这个错误是什么意思
[Error] no matching function for call to 'toupper(std::string&)'
【问题讨论】:
-
std::toupper接受 characters(更准确地说是一个字符int),而不是std::strings,作为其唯一参数。换句话说,错误消息准确地告诉您问题是什么。 -
这能回答你的问题吗? Convert a String In C++ To Upper Case
-
在互联网上搜索“c++ string transform toupper”。
-
我看了,没那么有用
-
@LolaBenson "我看了没那么有用" 哪方面没用?
标签: c++ arrays string toupper tolower