|
From: Abhijit S. <mu...@gm...> - 2002-12-26 19:01:58
|
Greets, Carlos.
> Happy new year tewnty three (hurra for the Empire!)
A Happy New Year to everyone.
>
> I need make an operation over a huge amount of files, basically I
> fstream.getline(buffer, 255); and then I do whatever. The problem is in
> all the files one line is treated badly:
>
> original:
>
> 3.429 145.1683002 5.4 0.908401 43.66
> 3.629 174.13 5.28 0.9093 42.86
> 3.859 175.61 5.14 0.909673 41.9
> 4.172 177.08 5.01 0.909293 40.8
> 4.649 178.56 4.91 0.908071 39.57
> However remains the question, why can it happen?
I tried a simple test program, it works fine with your input (FC returns no
differences). I'm running GCC 3.2. See if this program works with source.txt
being the above values.
----------- Start ------------
#include <iostream>
#include <fstream>
int main()
{
using std::cout;
using std::cerr;
using std::endl;
const int BUF_SIZE = 256;
char buf[BUF_SIZE];
std::ifstream in_file;
std::ofstream out_file;
in_file.open("source.txt");
if(!in_file)
{
cerr << "Couldn't open source.txt\n";
return 1;
}
out_file.open("dest.txt");
while(!in_file.eof())
{
in_file.getline(buf, BUF_SIZE);
out_file << buf << endl;
cout << buf << endl;
}
return 0;
}
---------- Stop ------------
Tell me what you get. If you get the error (or even if you don't), try
upgrading to the latest MinGW with GCC 3.2. The URL I used is
http://osdn.dl.sourceforge.net/sourceforge/mingw/MinGW-2.0.0-2.exe.
It may be out-dated now. Check the MinGW website.
___________________________________________________________
Abhijit Shylanath
E-mail: mu...@gm... || ibr...@bi...
Web-site: http://mudeth.tripod.com/
|