Forum Discussion
Altera_Forum
Honored Contributor
12 years agoformatting 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.
3 Replies
- Altera_Forum
Honored Contributor
sscanf() with %x will work for that task.
- Altera_Forum
Honored Contributor
Thanks Ted , it works.
Regards Ben - Altera_Forum
Honored Contributor
strtoul() is probably better - much smaller and with more appropriate error reporting.