text file will not read

Using g++ on a Dell Linux box Redhat 4.2.1

I have an application running two threads.

In the one thread I receive a table, I write a text file that now contains that table, one column, 400 items up to 4 characters long. The file writes correctly. The second thread never tries to use this file, and never will.

Very shortly after this, less than 1 sec, in the same thread, I receive another command that requires me to read out of that file. I can open the file, single stepping through the code looks like it is executing, but the variables are not being loaded. The filestream is not functioning correctly. I re-wrote the code using the C style ptr = fopen() approach and fscanf to read with the same results.

I am reading with the following syntax. And I do close the file after I write it. Have you ever seen anything goofy like this? I have tried declaring the variables as short, int, etc with no effect.



Filename >> variable;

Filename >> variable;



Filename >> variable;

For(i=0; i<40;i++){

Filename >> variable[i]};}

For(i=0; i<40;i++){

Filename >> variable[i];}



Filename >> variable;

For(i=0; i<40;i++){

Filename >> variable[i];}

For(i=0; i<40;i++){

Filename >> variable[i];}


Filename >> variable;

For(i=0; i<40;i++){

Filename >> variable[i];}

For(i=0; i<40;i++){

Filename >> variable[i];}

Filename >> variable;



Etc…..

I ran it in the ddd debugger which I figure slowed it down quite a bit between file creation/write and the open/read. The variables are still not being populated.

I suggest you cheching for the file state: when reached Filename.eof() you should stop reading
I'd like to see the binary contents of the file, possibly in hex.
Also, what's up with that reading mechanism? Is variable a pointer, an integer, or what?
Topic archived. No new replies allowed.