Click here to Skip to main content
16,006,382 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MDI Without DocView Pin
Christopher Lord24-Oct-01 14:39
Christopher Lord24-Oct-01 14:39 
GeneralRe: MDI Without DocView Pin
Christian Graus24-Oct-01 14:44
protectorChristian Graus24-Oct-01 14:44 
QuestionVC++ copy variables data? Pin
Todd Smith24-Oct-01 13:36
Todd Smith24-Oct-01 13:36 
AnswerRe: VC++ copy variables data? Pin
The_Server24-Oct-01 22:35
The_Server24-Oct-01 22:35 
GeneralFormatting Double Pin
AJ12324-Oct-01 12:20
AJ12324-Oct-01 12:20 
GeneralRe: Formatting Double Pin
Christian Graus24-Oct-01 12:28
protectorChristian Graus24-Oct-01 12:28 
Generalwsprintf does not work with doubles Pin
Tomasz Sowinski25-Oct-01 1:14
Tomasz Sowinski25-Oct-01 1:14 
GeneralRe: Formatting Double Pin
Mike Burston24-Oct-01 12:52
Mike Burston24-Oct-01 12:52 
You can also use the standard library "stringstream" class to format a std::string, like this :

double dTest = 10.329

std::stringstream ss;
ss << setiosflags( ios::fixed ) << setprecision(3) << dTest;
cout << ss.str();  // "10.329"

std::stringstream ss;
ss << setiosflags( ios::fixed ) << setprecision(2) << dTest;
cout << ss.str();  // "10.33"

std::stringstream ss;
ss << setiosflags( ios::fixed ) << setprecision(1) << dTest;
cout << ss.str();  // "10.3"


This looks like more code/work for such a simple example, but often this ends up saving you code if you then have to use the 'string' in other functions.

The standard library stringstream also has the advantage that you can extend it in two ways:
(a) writing your own manipulators (for example, you can write a 'percent' manipulator that converts a value into a percentage as it is written to the output;
(b) you can write inserters/extractors for user defined types, so that you can use the same syntax to write your own types as you do for the 'built in' types like double.

-----------------------
The sermon on the mount...

Man 1 : Hear that? Blessed are the greek.
Man 2 : The greek?
Man 1 : Well apparently, he's going to inherit the earth.
Man 2 : Did anyone catch his name?

General"STL & typedef problem" of MFC extened DLL programing Pin
24-Oct-01 11:37
suss24-Oct-01 11:37 
GeneralRe: "STL & typedef problem" of MFC extened DLL programing Pin
Christian Graus24-Oct-01 11:47
protectorChristian Graus24-Oct-01 11:47 
GeneralRe: "STL & typedef problem" of MFC extened DLL programing Pin
24-Oct-01 19:28
suss24-Oct-01 19:28 
GeneralRe: "STL & typedef problem" of MFC extened DLL programing Pin
Michael Dunn24-Oct-01 19:44
sitebuilderMichael Dunn24-Oct-01 19:44 
GeneralRe: "STL & typedef problem" of MFC extened DLL programing Pin
24-Oct-01 20:23
suss24-Oct-01 20:23 
GeneralRe: "STL & typedef problem" of MFC extened DLL programing Pin
Michael Dunn24-Oct-01 20:42
sitebuilderMichael Dunn24-Oct-01 20:42 
GeneralRe: "STL & typedef problem" of MFC extened DLL programing Pin
Steen Krogsgaard24-Oct-01 20:59
Steen Krogsgaard24-Oct-01 20:59 
GeneralRe: "STL & typedef problem" of MFC extened DLL programing Pin
Michael Dunn24-Oct-01 21:25
sitebuilderMichael Dunn24-Oct-01 21:25 
GeneralRe: "STL & typedef problem" of MFC extened DLL programing Pin
Steen Krogsgaard24-Oct-01 22:16
Steen Krogsgaard24-Oct-01 22:16 
GeneralRe: "STL & typedef problem" of MFC extened DLL programing Pin
Michael Dunn24-Oct-01 14:40
sitebuilderMichael Dunn24-Oct-01 14:40 
GeneralRe: "STL & typedef problem" of MFC extened DLL programing Pin
Christian Graus24-Oct-01 14:42
protectorChristian Graus24-Oct-01 14:42 
GeneralRepositioning a toolbar Pin
Walter Pak24-Oct-01 11:19
Walter Pak24-Oct-01 11:19 
GeneralRe: Repositioning a toolbar Pin
Christian Graus24-Oct-01 18:40
protectorChristian Graus24-Oct-01 18:40 
GeneralDatabase question Pin
Peter Molnar24-Oct-01 10:45
Peter Molnar24-Oct-01 10:45 
GeneralRe: Database question Pin
Michael P Butler24-Oct-01 11:21
Michael P Butler24-Oct-01 11:21 
GeneralRe: Database question Pin
Simon Walton24-Oct-01 11:28
Simon Walton24-Oct-01 11:28 
GeneralRe: Database question Pin
Michael P Butler24-Oct-01 11:38
Michael P Butler24-Oct-01 11:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.