• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++

learning c++ so not to good
but i need to know how to find the length of an integer and set that integer to an array and just can't seem to figure it out don't know a lot of the libraries that could help so something simply would be nice

so say int i = 1234

see that there are four numbers long
an array that has for example int a = l1l2l3l4l

thanks
 
For a more c++ish aproach: (Note: like previous solution, this is assuming that you want an array of character values, not actual integers)

 
see also: itoa() (Integer To ASCII), and atoi() (ASCII to Integer). These are from old-fashioned C, and work on raw char* buffers rather than std::string and std::stringstream. Note that only atoi() is part of the ANSI C spec; itoa() is pretty widely supported, but may not be in all compiler packages, especially older ones.

Also, in the post right above mine, I think you want

i >> buffer;

or

buffer << i;

and not

buffer >> i;

Unless std::stringstream defines the << and >> operators VERY strangely.
 
Back
Top