本文介绍了C ++ - 到UpperCase?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我知道有一个功能,但我似乎无法找到它。应该 是一种大写字母的方法吗? 这是我得到的。 cout << 输入书籍的标题以供查找:; cin>> firstString; if(strcmp(toupper(firstString),toupper(bookTitle [index]))== 0) 然后我检查他们在我的书标题数组中输入的书。怎么 我可以这么做,所以它把firstString和bookTitle都放到大写? 任何帮助都会很棒!谢谢! I know there is a function but I cannot seem to find it. There shouldbe a way to uppercase a char right? Here is what I got. cout << "Enter title of a book for look up: ";cin >> firstString; if (strcmp(toupper(firstString), toupper(bookTitle[index])) == 0) then i check the book they enter to a book in my bookTitle array. Howcan I make it so it puts both firstString and bookTitle to uppercase?Any help would be great! Thanks! 推荐答案 所以,它是一个数组,是吗?然后你需要遍历数组并且 对每个元素应用''toupper''。就这么简单。 V So, it''s an array, eh? Then you need to iterate through the array andapply ''toupper'' to every element. It''s that simple. V 如果你想让字符串全部大写,那么只需浏览 字符串并转换所有字符: const char * strtoupper(string str) { for(int i = 0; i< str.size(); i ++ ) str [i] = toupper(str [i]); 返回str.c_str(); } If you want to make the string all uppercase then just go through thestring and convert all the characters: const char* strtoupper(string str){for (int i=0;i<str.size();i++)str[i] = toupper(str[i]);return str.c_str();} 这篇关于C ++ - 到UpperCase?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 21:22