riteshshah
Programmer
Hi Guys,
Been looking at a problem with fscanf for a few days now. It seems to stop converting hex to binary (infile, "%2x", &ch ) towards the end of the data, although all the data is legit. Soo, I thought, because of some of the problems with the scanf family, I'd change to use fgets and then sscanf the resultant string. Now however, it seems to loop forever!!..
Any thoughts on how to get round this??
Much app'd!
<code>
dbuf = malloc( tifsize+1 );
memset(dbuf, ' ', tifsize+1);
fgets(dbuf, tifsize+1,infile);
while (sscanf(dbuf, "%2x", &ch )==1)
{
fputc(ch, outfile);
}
free (dbuf);
fclose(infile);
fclose(outfile);
<\code>
Been looking at a problem with fscanf for a few days now. It seems to stop converting hex to binary (infile, "%2x", &ch ) towards the end of the data, although all the data is legit. Soo, I thought, because of some of the problems with the scanf family, I'd change to use fgets and then sscanf the resultant string. Now however, it seems to loop forever!!..
Any thoughts on how to get round this??
Much app'd!
<code>
dbuf = malloc( tifsize+1 );
memset(dbuf, ' ', tifsize+1);
fgets(dbuf, tifsize+1,infile);
while (sscanf(dbuf, "%2x", &ch )==1)
{
fputc(ch, outfile);
}
free (dbuf);
fclose(infile);
fclose(outfile);
<\code>