ericm@ims.UUCP (Eric Martinson) (07/06/90)
I ran into what I am fairly confident is a bug in the Turboc C++ streams package. The following program is supposed to open a file, given as the first argument on the commant line, and display each line preceded by the lines offset in the file. SUN C++ translator generates the correct output. Turbo C++ succeeds in only generating the first line correctly. Every line after that is completely lost. #include <fstream.h> #include <iomanip.h> int main(int argc, char * argv[]) { if (!argv[1]) { cout << "No file name given\n"; return 1; } ifstream input_file; char input_line[256]; streampos input_pos=0L; input_file.open(argv[1]); if (!input_file) { cout << "Open failed!\n"; return 1; } while (!input_file.eof()) { input_pos = input_file.tellg(); //<<<----<<<<<< input_file.getline(input_line, 255, '\n'); cout << setw(5) << input_pos << setw(0) << ": " << input_line << '\n'; } } If the line marked with <<<----<<<<<< is removed from the code before compiling it with Turbo C++, it works but of course you can't tell where in the file the line comes from. There is the possibility that I don't quite understand what I'm doing. This doesn't seem likely here however. I got so frustrated with this that I called Borland. I agreed to download it to BIX (Byte Information eXchange) so they can have a look. Here's the real interesting point. I asked the tech support person if he could send me or tell me of known bugs in Borlands Turbo C++. He replies that management does not allow them to do that. In the past this was never a real issue because they didn't have any real blunders but with this release, that makes me very nervous. Anyone who can characterize the problem with the above code and provide more insight, please do so and post.