Complete.Org: Mailing Lists: Archives: discussion: March 2001:
[aclug-L] Re: c problems float to string
Home

[aclug-L] Re: c problems float to string

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: discussion@xxxxxxxxx
Subject: [aclug-L] Re: c problems float to string
From: Maverick <mluvw47@xxxxxxxxx>
Date: Fri, 23 Mar 2001 15:48:02 -0800 (PST)
Reply-to: discussion@xxxxxxxxx

should be pretty easy done by sprintf();
int sprintf(char *str, const char *format, ...);

//test.c
#include <stdio.h>
#define S_LEN 10

main() {
   char s[S_LEN];
   float f=123.0;
   bzero(s,S_LEN);
   sprintf (s,"%.1f",f);
   printf ("\ns is %s\n", s);
}


--- oceano <nathan@xxxxxxxxxxxxxxxx> wrote:
> 
> I'm designing a GUI using GTK+ and C via gcc.  I
> have hit a snag in not
> being able to convert a float value to a character
> string.  There are
> simple functions to go from string or character to
> float which I use but
> not the other way around? Can anyone help or will I
> have to suffer?
> 
> I would like to convert say, 123.0 to a string
> "123.0".
> 
> 
> -- This is the discussion@xxxxxxxxx list.  To
> unsubscribe,
> visit
>
http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi
> 


=====
~:~:~:~:~:~:~~:~:~:~:~:~:~~:~:~:~:~:~:~~:~:~:~:~:~:~~:~:~:~:~:~:~

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

-- This is the discussion@xxxxxxxxx list.  To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]