Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert number array to ascii digits

Status
Not open for further replies.

paul51

Programmer
May 19, 2000
38
0
0
US
I have the following:

unsigned int ARRAY[2000];
The array is filled with ints

e.g. ARRAY[0]=45,[1]=115,[2]=13, etc

I need an unsigned char buffer of '4','5','1','1','5' etc.

Does anyone know how to do the covnersion?

Thanks.
 
You can use itoa() in a loop if you like C functions, or you can use a stringstream in a loop if you like C++ objects. I'd go with the stringstream myself, since you don't have to worry about the size of the string buffer then.

Since you want unsigned char, you won't be able to use the default stringstream. You'll have to declare your own like this:
Code:
typedef basic_stringstream<unsigned char> ustringstream
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top