I've finally finished my program, but there is one bug I need to fix.

Basically, the user tells me their username, and then that's sent off to a ASP file to verify. However, if their username contains special characters such as a space, * or $ for example, the ASP file doesn't parse properly. The special characters need to be sent as the representations (%20 for space, %24 for $, %2A for * etc...).

I've tried using std::replace, but this doesn't replace properly (replacing * with 2 works, but not 2A or %2A). Any ideas? I'd really like to fix this ASAP as it's the only thing holding back completion of my program.

#include <iostream>
#include <string>

using namespace std;
int main()
{
    string str = "Hello*World";
    str.replace(5,1,"%2A");
    cout << str << "\n";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.