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

string.format help

I am java programmer thrust into the world of c++, wasn't that
competant in java to begin with so things just got harder. I have a
float that comes out of a database and I want to change it (to a
string) so that it is formatted to be say instead og 230000.00 to be
$230,000 Got told to use string.format but can't seem to find any
expressions that will allow me to format the string the way I want.
Any help will be appreciated.

Jan 20 '06 #1
6 6871
the best choice in c++ is boost::literal_cast<>
and the c-style sprintf() is an alternative approach

Jan 20 '06 #2
the best choice in c++ is boost::literal_cast<>
and the c-style sprintf() is an alternative approach

Jan 20 '06 #3
Thanks for your help I ended up using FloatToStrF with ffCurrency.

Jan 20 '06 #4
java <> c++ wrote:
Thanks for your help I ended up using FloatToStrF with ffCurrency.


Glad your program worked, but neither of those (FloatToStrF nor
ffCurrency) are Standard C++. They are part of some third party library.

Just so you'll know.

Jan 20 '06 #5
java <> c++ wrote:
I am java programmer thrust into the world of c++, wasn't that
competant in java to begin with so things just got harder. I have a
float that comes out of a database and I want to change it (to a
string) so that it is formatted to be say instead og 230000.00 to be
$230,000 Got told to use string.format but can't seem to find any
expressions that will allow me to format the string the way I want.
Any help will be appreciated.

Read up on stringstreams.

--
Ian Collins.
Jan 20 '06 #6
In message <11********************@z14g2000cwz.googlegroups.c om>,
feel_energetic <ge********@hotmail.com> writes
the best choice in c++ is boost::literal_cast<>
ITYM lexical_cast.
and the c-style sprintf() is an alternative approach


--
Richard Herring
Jan 24 '06 #7

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

Similar topics

7
by: Alpha | last post by:
Hi, I'm maintaining C# code and am fairly new with C# programming. I'm looking for codes that's droping the 2nd digit of a nuber printed out and I suspect it's the code below. Can someone tell me...
11
by: Matt | last post by:
string format formula to write a text file below is not working for me pos 1 to 10 name pos 15 to 30 lastname pos 45 to 75 job Adam smith programmer string fmt = "{1,10}{15-30}{45,75}"...
38
by: nobody | last post by:
I know that given a FormatString and a DateTime you can use DateTime.ToString(...) to convert the DateTime to a String. My question is how can you turn that around? Given a String and a...
4
by: Chris Dunaway | last post by:
I have a table in the database with a phone number field. The phone number is stored without any punctuation (e. g. 9995551234). I wish to take that string and format it for display (e. g. (999)...
3
by: scorpion53061 | last post by:
I have little hope of resolving this as I have had to contact outside help. But I thought I would post it here to see if anyone could add an idea or solution. 1. I have a form in a Class...
5
by: AMP | last post by:
Hello, I want to add some variables to a string and this isnt working. textBox1.Text="'BSL version='+ bslVerHi+ bslVerLo"; What am I doing wrong? Thanks Mike
8
by: Lucky | last post by:
hi guys! back again with another query. the problem is like this. i want to print a line like this: "---------------------------------------------" the easiest way is to simply assign it to...
3
by: shawrie | last post by:
Hello everyone can anyone please help me? I basically want to set the length of a string variable to help spacing my simple report out. i tried dim test as string(14) but it didnt like that
8
by: Armando Rocha | last post by:
Hi, Hi have a string with 16 chars "25DD68EDEB8D5E11" and i want show it in form like this "25DD-68ED-EB8D-5E11", i try String.Format("{0:####-####-####-####}", mystr), but not work, i think...
3
by: 6afraidbecause789 | last post by:
If able, can someone please help make a Where clause that strings together IDs in a multi-select listbox AND includes a date range. I wasn’t thinking when I used the code below that strings...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
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,...

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.