1

重複の可能性:
C++の文字列を大文字に変換する

こんにちは、C++の文字列を大文字に変換するためのポータブル関数が必要です。私は今toupper(char);を使用しています。働き。標準機能ですか?そうでない場合、プラットフォーム間でそれを行う正しい方法は何ですか?ところで、すべてのc++標準関数を一覧表示できるWeb/Wikiはありますか?ありがとうございました。

4

3 に答える 3

4

はい、ヘッダーtoupperで宣言されています。cctype次のアルゴリズムを使用して文字列を変換できます。

#include <algorithm>
#include <iostream>
#include <string>
#include <cctype>

int main()
{
    std::string str("hello there");
    std::cout << str << '\n';

    std::transform(str.begin(), str.end(), str.begin(), std::toupper);
    std::cout << str << '\n';
}
于 2010-11-17T13:02:27.670 に答える
1

後者の質問については、http://www.cplusplus.com/があります。

于 2010-11-17T12:59:44.440 に答える
0

こんにちは私たちのプロジェクトでは、WindowsとLinux用のboost / Algorithm /stringto_upper関数プロジェクトを使用しています

于 2010-11-17T13:01:56.970 に答える