473,378 Members | 1,444 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,378 software developers and data experts.

Converting AnsiString to double

Hello,

how can i convert a AnsiString to double?

I'm using C++ Builder 5 from Borland...

Greets,
Franz

--
() ascii ribbon campaign - against html mail
/\ - against microsoft attachments

Sep 17 '05 #1
9 9687
Franz Seidl wrote:
Hello,

how can i convert a AnsiString to double?

I'm using C++ Builder 5 from Borland...

Greets,
Franz

--
() ascii ribbon campaign - against html mail
/\ - against microsoft attachments

how about:

#include <iostream>
#include <string>
#include <sstream>

int main()
{
std::string pi("3.1459");

std::stringstream s(pi);
double d;

s >> d;

std::cout << "d is " << d << std::endl;
}

output:
d is 3.1459

Greg

Sep 17 '05 #2
Hello Greg,

is there a way to use a AnsiString (sorry but normally I'm
programming in Delphi, PHP, C#)?

Greets,
Franz
--
() ascii ribbon campaign - against html mail
/\ - against microsoft attachments

Sep 17 '05 #3
Franz Seidl wrote:
Hello Greg,

is there a way to use a AnsiString (sorry but normally I'm programming
in Delphi, PHP, C#)?

Greets,
Franz

Ask in a borland newsgroup.
Sep 17 '05 #4
red floyd schrieb:
Franz Seidl wrote:
Hello Greg,

is there a way to use a AnsiString (sorry but normally I'm programming
in Delphi, PHP, C#)?

Greets,
Franz

Ask in a borland newsgroup.


I was searching for it before. But my newsserver has only a pascal
newsgroup from borland... :(

Greets,
Franz

--
() ascii ribbon campaign - against html mail
/\ - against microsoft attachments

Sep 18 '05 #5
Franz Seidl wrote:
red floyd schrieb:
Franz Seidl wrote:
Hello Greg,

is there a way to use a AnsiString (sorry but normally I'm
programming in Delphi, PHP, C#)?

Greets,
Franz

Ask in a borland newsgroup.

I was searching for it before. But my newsserver has only a pascal
newsgroup from borland... :(

Greets,
Franz


Does AnsiString have some method to convert to a C string? I'm sure it does.

If so then you can use the sscanf function

AnsiString a = "12.34";
double d;
sscanf(a.some_method_to_convert_to_a_C_string(), "%lf", &d);

john
Sep 18 '05 #6
Hello John,

John Harrison schrieb:
Does AnsiString have some method to convert to a C string? I'm sure it
does.

If so then you can use the sscanf function

AnsiString a = "12.34";
double d;
sscanf(a.some_method_to_convert_to_a_C_string(), "%lf", &d);


Yes, you are right. There are a function called "a.c_str()"...

Thank you!

Greets,
Franz

--
() ascii ribbon campaign - against html mail
/\ - against microsoft attachments

Sep 18 '05 #7
Hi !

The Borland IDE is full of helpfull hints. Press F1 with the cursor on
the text 'AnsiString' and you will find the '.ToDouble()' function
under methods in the help menu.

Have fun

Sep 19 '05 #8
Franz Seidl wrote:
red floyd schrieb:
Franz Seidl wrote:
Hello Greg,

is there a way to use a AnsiString (sorry but normally I'm
programming in Delphi, PHP, C#)?

Ask in a borland newsgroup.


I was searching for it before. But my newsserver has only a pascal
newsgroup from borland... :(


use the web interface at http://newsgroups.borland.com/ .

Sep 19 '05 #9
Franz Seidl wrote:
Hello,

how can i convert a AnsiString to double?

I'm using C++ Builder 5 from Borland...

Greets,
Franz

--
() ascii ribbon campaign - against html mail
/\ - against microsoft attachments

So, I fire up trusty ole google and go off to see if we can find
anything that might do waht you're looking for.

Lo and behold, within about 5 seconds I find the strtod function
http://www.cplusplus.com/ref/cstdlib/strtod.html

Sep 19 '05 #10

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

Similar topics

20
by: Ollie | last post by:
Ok, As the Convert.ToDateTime has not been implimented yet, how do I convert a double to datetime??? I have looked all over with no luck at all. Please help me!
2
by: D. Shane Fowlkes | last post by:
Here's a good one. I've been using an Excel spreadsheet for the past couple of years to calculate a file's Estimated Download Time based off of a solid 50kbs connection (dial up). This is for a...
2
by: clintonb | last post by:
Victor said: The double value that I'm trying to convert to GCSMoney (which is implemented as cents) was produced by multiplying a dollar amount by an interest rate to get interest. double...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.