剑指OFFER 替换空格

剑指OFFER 替换空格

class Solution {
public:
	void replaceSpace(char *str,int length) {
        string s(str);

        size_t pos;
        while( (pos = s.find(' ')) != string::npos )
        {
            s.replace(pos,1,"%20");
        }
        
        
        for(int i=0;i<s.size();i++)
        {
            str[i]=s[i];
        }
        str[s.size()] = '';
        
        return;
	}
};
原文地址:https://www.cnblogs.com/virgildevil/p/12204096.html