need help for typecasting
How can you convert int type to const char*
_itoa_s(int, char*, size_t, int)
argv[0] - input integer
argv[1] - char array for output
argv[2] - size of the array at argv[1]
argv[3] - radix, i.e. number base
1 2 3
|
int a(12345);
char arr[6] = {0};
_itoa_s(a, &arr, sizeof(arr), 10); // using base 10
|
1 2 3 4 5 6 7 8 9 10
|
const char * text = "Some words.";
cout << text << endl;
int x = reinterpret_cast<int>(text);
cout << "x = " << showbase << hex << x
<< " or " << dec << x << endl;
const char * ptr = reinterpret_cast<const char *>(x);
cout << ptr << endl;
|
Some words.
x = 0x466064 or 4612196
Some words. |
Topic archived. No new replies allowed.