単語の最後の文字を文字列に変更したい。C++文字列[4]を文字列に変換する
ありがとうございました!
EDIT:
string x = "apple"; char c = apple[4]; string q = "";
string z = q+c;
単語の最後の文字を文字列に変更したい。C++文字列[4]を文字列に変換する
ありがとうございました!
EDIT:
string x = "apple"; char c = apple[4]; string q = "";
string z = q+c;
この作品ができます。それは彼の機能要件が何であるかにいくつかの洞察を提供してJonの未遂答えを追加しますか?あなたが文字を持っている場合
string x = "apple";
char c = apple[4];
string q = "";
string z = q+c;
コードを選択してから、101 010ボタンをクリックしてください。 –
これは 'string x =" apple ";文字列z(1、x [4]); ' –
std::string x = "apple";
std::string z(x.substr(4, 1));
は[] = "Laleluこれはために、言葉を選んだ単語:P" []編曲:CHAR言うことができます。
次にあなたが試みることができる:
std::string str; str.assign(&arr[strlen(arr)-5], 4);
これを試してみてください。..
std::string apple = "apple";
std::string fpp(apple.rbegin(), apple.rbegin() + 1);
このような何か試してみてください:私はへのアクセス権を持っていないとして、テストされていない
string MyString = "Whee!"; // String to extract letter from.
char LastChar = MyString.at(MyString.length() - 1); // Retrieves the last letter of the string and stores it as a char.
string LastCharAsString = string(1, LastChar); // Typecasts the char to a string.
をコンパイラATM。
うん...何ですか?これまでに得たことを示すコードを投稿して、達成したいことの例を教えてください。 –
あなたは何を求めているのか分かりません。 – pisfire
のような単語は、C文字列ですか?文字列クラスがオーバーロードされています=演算子。 –