URLとして使用する文字列を準備する方法を探しています。
コードの基本は、探しているものを入力すると、入力した内容でブラウザーが開きます。私はC ++を学習しているので、これは学習プログラムです。そして、私はC ++を初めて使用するので、できるだけ具体的にしてください。
これが私がやろうとしていることです:
cin >> s_input;
transform(s_input.begin(), s_input.end(), s_input.begin(), tolower);
s_input = "start http://website.com/" + s_input + "/0/7/0";
system(s_input.c_str());
しかし、ユーザーが入力するすべてのスペースを「%20」に置き換えようとしています。私はこの方法で1つの方法を見つけましたが、一度に1つの文字でしか機能せず、文字の配列ではなく完全な文字列でそれを行う必要があります。これが私が試した方法です:
cin >> s_input;
transform(s_input.begin(), s_input.end(), s_input.begin(), tolower);
using std::string;
using std::cout;
using std::endl;
using std::replace;
replace(s_input.begin(), s_input.end(), ' ', '%20');
s_input = "start http://website.com/" + s_input + "/0/7/0";
system(s_input.c_str());
ご協力いただきありがとうございます!