For example: Before Document: hai hello my daily salary is two thousand and five and your salary is five billion. my age is twenty-five. After Document: hai hello my daily salary is # and your salary is #. my age is #. All the text numbers and i put the # symbol.. Please give me the correct code.. I am trying this code:
#include <iostream> #include <fstream> #include <string> using namespace std; ifstream myfile_in ("sample.txt"); ofstream myfile_out ("Lista2.txt"); string line; void find_and_replace( string &source, string find, string replace ) { size_t j; for ( ; (j = source.find( find )) != string::npos ; ) { source.replace( j, find.length(), replace ); } myfile_out << source <<endl; cout << source << endl; } int main () { if (myfile_in.is_open()) { int i = 0,j; //string strcomma ; // string strspace ; while (! myfile_in.eof() ) { getline (myfile_in,line); string strcomma= "two"; string strspace = "#"; find_and_replace( line , strcomma , strspace ); i++; } myfile_in.close(); } else cout << "Unable to open file(s) "; system("PAUSE"); return 0; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)