Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

formatting char to 4 bits

Altera_Forum
Honored Contributor II
996 Views

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 II
295 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
295 Views

Thanks Ted , it works. 

 

Regards 

 

Ben
0 Kudos
Altera_Forum
Honored Contributor II
295 Views

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

0 Kudos
Reply