#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
int main()
{
string str="ali maqood is good prorammer";
int position;
position=str.find(" "); // find the blankspace from the string
while(position!=string::npos) // npos means if no position find
{
str.replace(position,1,"," ); // repace string with ","
position=str.find(" ",position+1); // increment in the position
str.replace(22,1,"g" ); // again repace "g" on position 22 s
}
cout << str;
getch();
}
#include<conio.h>
#include<string>
using namespace std;
int main()
{
string str="ali maqood is good prorammer";
int position;
position=str.find(" "); // find the blankspace from the string
while(position!=string::npos) // npos means if no position find
{
str.replace(position,1,"," ); // repace string with ","
position=str.find(" ",position+1); // increment in the position
str.replace(22,1,"g" ); // again repace "g" on position 22 s
}
cout << str;
getch();
}