Re: fscanf hangs
- From: PeterOut <MajorSetback@xxxxxxxxxx>
- Date: Sat, 30 Jun 2007 11:11:12 -0700
On Jun 26, 12:19 am, Barry Schwarz <schwa...@xxxxxxxxx> wrote:
MUCH more than worth it. I have replaced a black box that hangs with
This sure seems like a lot of work just avoid calling fgets.
much more transparent code that does not. If it did hang or crash, I
would have a much better idea of why.
Excellent point. I will modify FReadLine() so that there is a maximum
Is 32 bytes really sufficient to hold the longest line in your file?
to the number of characters that are read.
do
{
if ((enErrorNumber=FReadLine(fpFile, csBuffer))!=ERROR_NONE) break;
lX=atoi(strtok(csBuffer, "\t"));
lY=atoi(strtok(NULL, "\t"));
fMean=(float)atof(strtok(NULL, "\t"));
The cast is superfluous.
fMean=atof(strtok(NULL, "\t"));
warning C4244: '=' : conversion from 'double' to 'float', possible
loss of data
So far no problem.
So you have managed to camouflage the problem with no understanding of
what the real issue was?
I may have evaded the issue but have replaced a black box, that hangs
with no error message, with more transparent code. fscanf probably
hung because it was waiting for a particular input. It was not
suitable for this application since the expected input may not have
been in the input file. I think my modification has given me more
control and has made the code potentially more robust.
Thanks,
Peter.
.
- Follow-Ups:
- Re: fscanf hangs
- From: Richard Heathfield
- Re: fscanf hangs
- References:
- Re: fscanf hangs
- From: Barry Schwarz
- Re: fscanf hangs
- Prev by Date: Re: storing related structs
- Next by Date: Re: reply the answer
- Previous by thread: Re: fscanf hangs
- Next by thread: Re: fscanf hangs
- Index(es):
Relevant Pages
|
|