My function to delete a character is called "conv":
#include <cstdlib> #include <iostream> #include <string> using namespace std; string conv(string first, char chr) { string ret,s="x"; for (int i=0;i<first.length();i++) { if (first[i]!=chr) s=s+first[i]; } first=s; first.erase(0,1); ret=first; return ret; } int main() { string two,casper="testestestest"; const char x='t'; cout<<conv(casper,x); system("PAUSE"); return 0; }
You need to change const char x to ' ' (space, blanco) to complete the job. Hope this helps.
source share