To have a stab at it;
Code:
#include <iostream>
#include <string>
int main(){
using std::cout;
using std::endl;
using std::string;
string one("Hello World This Is Encoded");//string to encode
const string rep("%2B");//replacement token
string::size_type indxD = 0;//return of find...
std::cout << "Unencoded " << one << std::endl;
while(1){
indxD = one.find_first_of (' ',0);//find a char....
if(indxD == string::npos)break;//if -1 then end (not found!)
else one.replace(indxD,1,rep.c_str(),rep.length());//replace with token
}
std::cout << "Encoded " << one << std::endl;
}