Re: fscanf hangs



On Jun 26, 12:19 am, Barry Schwarz <schwa...@xxxxxxxxx> wrote:

This sure seems like a lot of work just avoid calling fgets.

MUCH more than worth it. I have replaced a black box that hangs with
much more transparent code that does not. If it did hang or crash, I
would have a much better idea of why.

Is 32 bytes really sufficient to hold the longest line in your file?

Excellent point. I will modify FReadLine() so that there is a maximum
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.

.



Relevant Pages

  • Re: Mp3 warning: pure jazz! - Beautiful Love take 1 - guitar trio
    ... try to listen to his clips I get about 10 seconds worth of music, ... then it hangs. ... PC/firefox as well as Mac/Safari. ...
    (rec.music.makers.guitar.jazz)
  • Re: Adobe nags
    ... Mike Ruddock wrote: ... hangs for about half a minute and then up comes some stuff from Adobe ... How can i stop thsi nonesense? ... Is the 8.1 version worth having ...
    (uk.media.radio.archers)
  • Re: PLATE MAPS OF THE PAST
    ... >> supported by a nickel's worth of data is ... The fact that he hangs out with JPT ...
    (sci.geo.geology)
  • Illustrator 10 on OS 10.4.x
    ... but hangs on "Loading Startup Settings". ... Is it worth trying to get this version of Illustrator to work with ...
    (comp.sys.mac.apps)