delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/28/22:21:46

Sender: nate AT cartsys DOT com
Message-ID: <36FEF10C.BEDA5726@cartsys.com>
Date: Sun, 28 Mar 1999 19:18:36 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.3 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: converting variables
References: <7dk0c8$v0e$1 AT nnrp1 DOT dejanews DOT com>
Reply-To: djgpp AT delorie DOT com

ryan_brown AT my-dejanews DOT com wrote:
> 
> How can I convert values from a variable of one type to another variable of a
> different type?  I need to convert a float variable over to a char variable.
> In pascal there were functions for this in c I can't find anything.  I have
> heard of casting but I can't get it to work and there isn't any documentation
> about it anywhere. 

Casting *is* the way to accomplish such a task.  Please post some code
that doesn't work for you.

If you're learning C, you ought to have a book or similar reference, and
that will explain casting.

> Someone also told me that you can't cast between float
> and char.

I don't think this is true.  Admittedly, it's likely to overflow, but
that's a separate issue.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019