G-Force
LPSTR lp;
int i = 1;
_itoa(i, lp, 10);
The correct code is:
char buf[10];
int i = 2;
_itoa(i, buf, 10);
G-Force wrote in message ...
must likely you are using an uninitialized pointer. One function I use a lot is
wsprint(), like this:
int myint = 18;
char number[20];
wsprintf ( number, "%d", myint );
--
Tomas Restrepo
win...@bigfoot.com
http://members.xoom.com/trestrep/
G-Force <jaa...@usa.net> wrote in message news:e0rSwNBk#GA.261@cppssbbsa03...
--
Truth,
James [MVP]
http://www.NJTheater.Com -and-
http://www.NJTheater.Com/JamesCurran
G-Force wrote in message ...
{
char buffer[20];
int i = 3445;
_itoa(i, buffer, 10);
printf( "String of integer %d (radix 10): %s\n", i, buffer );
}
Vincent
G-Force wrote in message ...
>How to do this, _iota gives an access violation with my comp, maybe
>something wrong with my
>settings?
>
>G-Force
>
>
#include <sstream>
int main()
{
int n = 12345;
std::ostringstream format;
format << n;
std::cout << format.str() << endl;
}
Obviously, this is a contrived example, but, you get the idea. format.str()
returns an std::string. If you would like a C-style string, you can say
'format.str().c_str()'. The biggest advantage to this is you have complete
type safety. If you ever need to change 'n' to a different type (e.g., from
int to long), you do not have to make any changes to your conversion code.
--
- Barry L. Wallis
- Oceanside, California, USA