943,729 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4639
  • C++ RSS
Sep 4th, 2003
0

Finding and Replacing Strings

Expand Post »
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;

}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
blackspyder01 is offline Offline
2 posts
since Sep 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C++ Forum Timeline: Error Linking KeyLogger.exe
Next Thread in C++ Forum Timeline: Canvas and shape problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC