#include <iostream>
#include <string>
void removeSpaces(std::string);
int main()
{
std::string inputString;
std::cout<<"Enter the string:"<<std::endl;
std::cin>>inputString;
removeSpaces(inputString);
return 0;
}
void removeSpaces(std::string str)
{
size_t position = 0;
for (position = str.find(" "); position != std::string::npos; position = str.find(" ",position))
{
str.replace(position ,1, "%20");
}
std::cout<<str<<std::endl;
}
出力が表示されません。たとえば、C++で文字列の空白を%20で置換する
Enter Input String: a b c
Output = a
何か問題がありますか?
を可能重複は、文字列で使用されるカント? C++](http://stackoverflow.com/questions/4992229/spaces-cant-be-used-in-string-c) –