Finding and Replacing Strings

Please support our C++ advertiser: Intel Parallel Studio Home
Closed Thread

Join Date: Sep 2003
Posts: 2
Reputation: blackspyder01 is an unknown quantity at this point 
Solved Threads: 0
blackspyder01 blackspyder01 is offline Offline
Newbie Poster

Finding and Replacing Strings

 
0
  #1
Sep 4th, 2003
I kinda have a problem. What i'm tryin to do is read a couple or lines or so from a text file and then replace all the gender pronouns ie(he, she, him, her) and replace those with gender neutral ones. The problem i'm having is trying to find all the gender pronouns and replacing them Her is a example of my code so far. Any help would be a God send.

#include<iostream>
#include<string>
#include<fstream>


using namespace std;

int main()
{
ifstream gender;
gender.open("Proj1.txt");
string str1="", str2=" he", str3=" she", str4=" him", str5=" her",str;
int pos =0;
if (gender.is_open())
{


while(!gender.eof())
{
getline(gender, str1);
pos=str1.find(str2,0);
cout<<str1.replace(pos, 3, " he or she"<<endl;

getline(gender, str1);
}
}


gender.close();


return 0;

}
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC