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++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

converting integers to strings and vice versa

Altera_Forum
Honored Contributor II
1,601 Views

I have an integer, 255, that I would like to convert to the string "255" for file IO. Any idea how I can do this? 

 

Thanks, 

 

Andrew
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
905 Views

Either use sprintf() or itoa(). 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
905 Views

Or write your own. I have one. I'll see if I can find it. 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
905 Views

sprintf() is the more standard way to do this. If you want something light weight use a loop and %10 and /10 operations to pluck out the characters (I'm pretty sure that's how itoa() works).

0 Kudos
Reply