PDA

Click to See Complete Forum and Search --> : Converting data types


softwareguy74
Jan 4th, 2001, 12:15 PM
Hi,

I was wondering if someone could just give me a quick run down of how you convert datatypes to other datatypes in C++.

For example, how would I convert an int value to a string value?

Any help would be appreciated..

Dan

parksie
Jan 4th, 2001, 12:31 PM
For the basic types, you can cast between them:

long val;
int other = 2;

val = (long)other;

For a string, use:

char buf[40];
int num = 50;
int radix = 10; // number base

itoa(num, buf, radix);