Thread View: alt.comp.lang.learn.c-c++
1 messages
1 total messages
Started by Obsession
Fri, 15 Jun 2001 20:47
program runs ok on Win2K, wrong on 98
Author: Obsession
Date: Fri, 15 Jun 2001 20:47
Date: Fri, 15 Jun 2001 20:47
70 lines
3565 bytes
3565 bytes
Hi
First of all I want to say I use Borland Turbo C++ 3.0 (1992). It's
something for school.
Below is the part I'm having difficulties with.
void read_from_file()
{
FILE *stream_read;
Timer timer_read;
float h;
char l[5],m[11];
int to_output;
stream_read=fopen("c:\\gip\\route.txt","r");
do
{
fgets(l,5,stream_read); // 2 chars + \n
fgets(m,11,stream_read);
h=atof(m);
if(feof(stream_read)) break;
to_output=atoi(l);
outportb(680,to_output);
do
{
timer_read.start();
timer_read.stop();
}
while(timer_read.time()<=h);
fgets(l,2,stream_read); // 2= \n I use an extra \n while writing the file.
timer_read.reset();
}
while(!feof(stream_read));
fclose(stream_read);
outtextxy(45,150,"End of file");
getch();
}
Before this function is called, I write to a file what has to be sent to
port 680, then run a timer to see how long it has to be sent and write that
also to the same file (on a new line). This is followed by an empty line,
just so I can see it clearly when I open the file in notepad. Then the
function above is called to simply redo what I just did.
What happens first is I read from the file what I have to output (int) and
how long (float).
Then the Do while loop starts, starting and stopping the timer quickly and
see if it has been running longer than it states in the file. If it hasn't
it will continue to start & stop the timer until it has been running at
least that long. And that happens until EOF.
The real problem is that this works ok on Win2k, it takes approximately the
same time (+- 1sec difference) to do the thing I told it to do when I wrote
that stuff to a file.
But on windows 98, two things can happen
#1 It just doesn't get through the loop
#2 It goes through the file in a matter of milliseconds, while in the file
it states that the total time is maybe 25 seconds.
this differs from pc to pc and neither one gives an error
How is this possible ?
Sorry for the crossposting, but in 'borland.public.cpp.turbocpp' are only a
few posts so I crossposted it to make sure I get a reply.
Thank you.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads