Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   changing datatypes (http://www.velocityreviews.com/forums/t275963-changing-datatypes.html)

sudip chatterjee 07-23-2003 05:19 PM

changing datatypes
 
can a signed 'int', 'long' or 'double' datatype be changed int 'char'
without using any standard library functions...

sudip

John Harrison 07-23-2003 05:23 PM

Re: changing datatypes
 

"sudip chatterjee" <monarchofindia@hotmail.com> wrote in message
news:828df4f5.0307230919.391ba559@posting.google.c om...
> can a signed 'int', 'long' or 'double' datatype be changed int 'char'
> without using any standard library functions...
>
> sudip


Sure

int i = 1;
int l = 2;
double d = 3;
char c1 = i;
char c2 = l;
char c3 = d;

is that what you meant?

john



John Dibling 07-23-2003 05:24 PM

Re: changing datatypes
 
On 23 Jul 2003 10:19:44 -0700, monarchofindia@hotmail.com (sudip
chatterjee) wrote:

>can a signed 'int', 'long' or 'double' datatype be changed int 'char'
>without using any standard library functions...
>
>sudip


Sure, but you will have to use some function to do basically what
itoa() and sprintf() do. You might even have write that function
yourself. There is nothing magic in any of the standard library
functions, just code.

BTW - I am assuming you are trying to get a number formatted as a
string, as accomplished like this: sprintf( psz, "%i",
nNumberToFormat);

</dib>

John Dibling
email: dib@substitute_my_full_last_name_here.com
Witty banter omitted for your protection

John Harrison 07-23-2003 05:24 PM

Re: changing datatypes
 
>
> int i = 1;
> int l = 2;


I meant to type

long l = 2;

john




All times are GMT. The time now is 04:34 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.