Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
728 Views

formatting char to 4 bits

Hello , In C , I am looking for a way to convert a char string , for example (0580) (4*8 bits) into (0580) (4 * 4bits) , other example : (0FED) (4 * 8 bits) into (0FED) (4 * 4 bits). Thanks for your help.

0 Kudos
3 Replies
Altera_Forum
Honored Contributor I
27 Views

sscanf() with %x will work for that task.

Altera_Forum
Honored Contributor I
27 Views

Thanks Ted , it works. 

 

Regards 

 

Ben
Altera_Forum
Honored Contributor I
27 Views

strtoul() is probably better - much smaller and with more appropriate error reporting.

Reply