hey ^^
Well, I got a hold of Borland C++ Builder 6 trial, so it's all good now I guess. However my friend still wants me to use TurboC++ 3.01 for DOS, so if you know how to make TLINK.EXE work correctly, or what are the environment variables to configure so it works, I would be very, very glad .
Anyways, this is not just advertisement... >_>;; as I didn't want to lose time waiting for a solution to my TC++ problem, I'm trying with BC++ 6 trial, and got this far:
Code:
#include <iostream.h>
#include <fstream.h>
#include <string.h>
using namespace std;
/***********************************************************************
************************************************************************
***********************************************************************/
int main()
{
string LineNEW, LineOLD;
int line;
ifstream esp ("new.txt", ios::in);
ifstream old ("old.txt", ios::in);
ofstream to ("output.txt", ios::out);
if (!esp.is_open()){ cout << "Error loading new.txt\n"; getchar(); return 0; }
if (!old.is_open()){ cout << "Error loading old.txt\n"; getchar(); return 0; }
if (!to.is_open()){ cout << "Error creating output.txt\n"; getchar(); return 0; }
while (! esp.eof())
{
line += 1;
getline (esp, LineNEW);
getline (old, LineOLD);
cout << "New: " << LineaESP << endl;
cout << "Old: " << LineaOLD << endl << endl;
}
cout << "Finished.";
esp.close();old.close();to.close();
getchar();
return 0;
}
I need to read two files, compare strings between the two, and if there needs something to be replaced, write it in output.txt, along with the unchanged stuff.
I would like to know if it's possible to move the read pointer to the previous/next line, or to a specific one, instead of abstract positions I get when using tellg() and seekg()... or how to read/write files using LINES instead of pointers and positions and all that "detailed small stuff". And, if it's possible, to have an independent position between New and Old, so like, if Line #2 in New does not match Line #2 in Old, move to the next line in Old so it matches Line #2 in New... that's for avoiding line breaks and such (the two files have the same structure, though sometimes they're separated with more than one line break, so I'd like to manually handle that).