Read In Hex Values (C) -


I am currently trying to read from a text file in hex values.

There may be multiple lines of hex and each row may be as important:

  f53d6d0568c7c7ce 1307a7a1c84058 b41af04b24f3eb83ce  

Currently, I have a simple loop to read in hex values ​​with Fscanf in a unsigned char line [500] in: like:

 for  (i = 0; i & Lt; 500; i ++) {if (fscanf (fp, "% 02x", and line [i])! = 1) break; }  

At the present time, it reads only in the first line, as well, it's definitely not the best way to throw random 500 in order to read.

I was thinking that I was sscanf with fgets or some of that nature but I was not sure that this would be the best way.

If someone can help me point in the right direction, then I appreciate it.

You can see the fgets () and sscanf () With ; That you will give everything properly if your data is actually in that format, then sscanf () can be overkill; You can just type a quick conversion loop and save all those funidious function calls.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -