我正在進行一項練習,將字詞存儲在<vector>
的string
s中,然後將所有字母轉換爲大寫,並且每行打印出8個字。除了toupper()
我的代碼的一部分,一切正常。這一切是:不能讓toupper與矢量一起工作
vector<string> words;
string theWords;
string word;
while(cin >> word)
words.push_back(word);
for(auto &i : words) {
word = i;
for(auto &j: word)
j = toupper(j);
}
int k = 0;
for(auto i : words) {
cout << i << " ";
++k;
if(k % 8 == 0)
cout << endl;
}
歡迎來到Stack Overflow。爲了最好地回答問題,你應該總是嘗試發佈一個[sscce](http://sscce.org/),你期望輸出/行爲是什麼以及你看到的輸出/行爲。如果您有編譯錯誤,請發佈編譯器錯誤。 http://stackoverflow.com/questions/how-to-ask – kfsone
我以前沒有遇到過。我將來會這樣做,謝謝。 – spartanhooah