Its me again, I was wondering if some one can give me some guidelines about how to Find and replace a string after reading it from a file using i/o commands I mean, I have a file that I opened and read the context of it with the ftream functions shown as below:
Expand|Select|Wrap|Line Numbers
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- #include <fstream>
- using std::ifstream;
- using std::ofstream;
- #include <stdio.h>
- #include <cstdlib>
- #include <string>
- #include <stdlib.h>
- #include <iomanip>
- #define MAXLENGTH 256
- int _tmain(int argc, _TCHAR* argv[])
- {
- char MyWord[MAXLENGTH];
- char *MyString;
- ifstream ReadWord;
- ofstream WriteWord;
- ReadWord.open("file.txt");
- WriteWord.open("file.dat");
- if(!WriteWord)
- {
- cerr<<"couldn't create file"<<endl;
- exit(1);
- }
- if (!ReadWord)
- {
- cerr<<"not found"<<endl;
- exit (1);
- }
- while(!ReadWord.eof())
- {
- ReadWord.getline(MyWord,MAXLENGTH);
- // ReadWord>>MyWord;
- MyString=MyWord;
- cout<<MyString<<endl;
- // WriteWord<<MyString<<endl;
- }
- ReadWord.close();
- WriteWord.close();
- return 0;
- }