473,394 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Convert float -> char*

ern
Anybody know the Linux equivalent (or even better some C standard
equivalent) for _gcvt() ? I want my float to become a char*. Thanks!

Nov 15 '05 #1
8 3097
ern wrote:
Anybody know the Linux equivalent (or even better some C standard
equivalent) for _gcvt() ? I want my float to become a char*. Thanks!

The standard way is to use sprintf() or, likely better, snprintf()
(standard in C99).

BTW - have you read the FAQ?

HTH,
--ag

--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com (new post 8/5)
http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"
Nov 15 '05 #2
ern
>BTW - have you read the FAQ?

No, where is it?

Nov 15 '05 #3
ern wrote
(in article
<11*********************@z14g2000cwz.googlegroups. com>):
BTW - have you read the FAQ?


No, where is it?


GIYF

--
Randy Howard (2reply remove FOOBAR)

Nov 15 '05 #4
ern

Randy Howard wrote:
ern wrote
(in article
<11*********************@z14g2000cwz.googlegroups. com>):
BTW - have you read the FAQ?


No, where is it?


GIYF

--
Randy Howard (2reply remove FOOBAR)


Yes I know, but I've tried for a few hours now and I can't find what
I'm looking for.

Nov 15 '05 #5
ern
Thanks, finally got something that worked here:

http://www.cplusplus.com/ref/cstdio/sprintf.html

float value = 0.2623452345
char sValue[50];
sprintf(sValue,"%.7f",value);
printf("string version is %s\n",sValue);

Nov 15 '05 #6
ern wrote
(in article
<11**********************@o13g2000cwo.googlegroups .com>):

Randy Howard wrote:
ern wrote
(in article
<11*********************@z14g2000cwz.googlegroups. com>):
BTW - have you read the FAQ?

No, where is it?


GIYF

--
Randy Howard (2reply remove FOOBAR)


Yes I know, but I've tried for a few hours now and I can't find what
I'm looking for.


You tried for 2 hours to type in "comp.lang.c FAQ" and failed?
You might want to try something other than programming as a
career.
--
Randy Howard (2reply remove FOOBAR)

Nov 15 '05 #7
"ern" <er*******@gmail.com> wrote in news:1128355033.846938.126060
@o13g2000cwo.googlegroups.com:

Randy Howard wrote:
ern wrote
(in article
<11*********************@z14g2000cwz.googlegroups. com>):
>> BTW - have you read the FAQ?
>
> No, where is it?


GIYF

Yes I know, but I've tried for a few hours now and I can't find what
I'm looking for.


http://www.google.com/search?q=comp.lang.c.+FAQ

Not that hard, is it?
--
A. Sinan Unur <1u**@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
Nov 15 '05 #8
"ern" <er*******@gmail.com> writes:
Randy Howard wrote:
ern wrote
(in article
<11*********************@z14g2000cwz.googlegroups. com>):
>> BTW - have you read the FAQ?
>
> No, where is it?


GIYF


Yes I know, but I've tried for a few hours now and I can't find what
I'm looking for.


Remarkable.

Google "C FAQ"; it's the first hit.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Cally | last post by:
Hello, I would like to convert a field from ntext field found in one database table to float field found in another database table. The reason why I want to do this is a long one. I have...
9
by: GRoll21 | last post by:
I have a program here that asks the number of students surveyed. then it will ask how many movies each student has watched. After thats been collected it does functions to find the average, median,...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
2
by: Chi Tang | last post by:
Hi, I try to convert a string to a float but it alway comes out with extra value. For example, the string input is '12.6' but the output is '12.6000003814697' The following is my code to do...
2
by: Alberto | last post by:
why there isn't a Convert.ToFloat() method in the Convert class? Sometimes I can't work with a float field because there isn't this method and I need it to, for example, convert the input in a...
4
by: Gav | last post by:
Hi all, I have a value in a database which is of float and in order to get my value from my textbox into my database I am doing something along the line of sqlparm1.value=...
4
by: viks | last post by:
Hi guys I need little help here . I want to convert 'System::Object __gc * array ' to 'float array' Lets say I have object Reader with method Send ,it returns a variant that contains a...
4
by: Pixie Songbook | last post by:
Hi, I'm trying to write a program using the Dev C++ 4.9.9.2 compiler that takes input numbers from a word document, sums them together, and then gives me a result. It should be easy as the book I...
2
by: trondhuso | last post by:
Hi group, I've found some code that I want to use in a project that I am working on, but the code is for c# .net and not 2003 or 2005 that I have available. In this code the program yells on...
9
by: Marco Nef | last post by:
Hi there I'm looking for a template class that converts the template argument to a string, so something like the following should work: Convert<float>::Get() == "float"; Convert<3>::Get() ==...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.