473,765 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3117
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************ *********@z14g2 000cwz.googlegr oups.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************ *********@z14g2 000cwz.googlegr oups.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",valu e);
printf("string version is %s\n",sValue);

Nov 15 '05 #6
ern wrote
(in article
<11************ **********@o13g 2000cwo.googleg roups.com>):

Randy Howard wrote:
ern wrote
(in article
<11************ *********@z14g2 000cwz.googlegr oups.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*******@gmai l.com> wrote in news:1128355033 .846938.126060
@o13g2000cwo.go oglegroups.com:

Randy Howard wrote:
ern wrote
(in article
<11************ *********@z14g2 000cwz.googlegr oups.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.u de.invalid>
(reverse each component and remove .invalid for email address)
Nov 15 '05 #8
"ern" <er*******@gmai l.com> writes:
Randy Howard wrote:
ern wrote
(in article
<11************ *********@z14g2 000cwz.googlegr oups.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_Keit h) 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
18536
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 tried the following and playing around with the following: declare @valuePointer varbinary(16)
9
2454
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, and mode. The problem I am having is getting it to return the mode. I have a function set up but I'm not sure if it will correctly return the mode. I am getting 1 error. c:\C++\math\math.cpp(49): error C2664: 'getMode' : cannot convert...
4
9768
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 numeric value according to an arbitrary regular expression.
2
64489
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 the convert: float fBalance = (float)System.Convert.ToSingle("12.6"); Should I specify a format string for the convert? Thanks for any help, CT
2
22256
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 textBox to a float field. Thank you
4
2395
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= (float)Convert.ToDouble(textbox1.Text); however if I say put in 7.8 it saves it as 7.800000190
4
6077
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 one-dimensional array of float value . I m trying to do something like this.
4
25099
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 have tells me what to do, problem is I get the error message "cannot convert `float' to `float*' for argument `1' to `float array_sum(float*, int)' " for line 22 of the program. This is what I have; #include <iostream.h> #include <fstream.h> ...
2
2334
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 (float)Convert.ToDouble(xml.value) (which in this case is "8.25"). I am wondering if someone could tell me how the command is changed in 2003 or 2005 as it stops here.
9
17569
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() == "3"; Convert<HelloWorld>::Get() == "HelloWorld"; The reason I need this is that in our design every class of a certain
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.