Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to convert TCHAR to char Pin
transoft10-Feb-06 10:41
transoft10-Feb-06 10:41 
AnswerRe: How to convert TCHAR to char Pin
willy_total10-Feb-06 10:46
willy_total10-Feb-06 10:46 
AnswerRe: How to convert TCHAR to char Pin
try8810-Feb-06 15:43
try8810-Feb-06 15:43 
AnswerRe: How to convert TCHAR to char Pin
Ryan Binns12-Feb-06 17:22
Ryan Binns12-Feb-06 17:22 
QuestionNeed help in writing c program plzzzzzzzzzzz Pin
samsams10-Feb-06 9:56
samsams10-Feb-06 9:56 
AnswerRe: Need help in writing c program plzzzzzzzzzzz Pin
George L. Jackson10-Feb-06 10:11
George L. Jackson10-Feb-06 10:11 
AnswerRe: Need help in writing c program plzzzzzzzzzzz Pin
perlmunger10-Feb-06 11:27
perlmunger10-Feb-06 11:27 
QuestionI really do hate string streams Pin
PJ Arends10-Feb-06 9:49
professionalPJ Arends10-Feb-06 9:49 
The entire test project can be downloaded at http://www3.telus.net/pja/pja_format.zip. I am planning to write an article on this so I do not mind sharing what I got so far.

This is my header file:
#pragma once
 
#define USE_STRSTREAM
 
#ifdef USE_STRSTREAM
#include <strstream>
#else
#include <sstream>
#endif
 
class pja_format
{
...
public:
    // convert any type to a string using the inserter << operator
    template <class T> static const char * tostring (const T &t)
    {
#ifdef USE_STRSTREAM
        std::strstream s;
#else
        std::ostringstream s;
#endif
        s.setf(std::ios::fixed);
        s.precision(precision);
        s << t << std::ends;
#ifdef USE_STRSTREAM
        return s.str();
#else
        return s.str().c_str();
#endif
    }

    // explicit override of the tostring function for the bool type
    template<> static const char * tostring (bool b)
    {
        return b ? "true" : "false";
    }
};
I have got the demo working in ANSI if I use strstream, but I want to port it to work with UNICODE now, so I have to switch from strstream to stringstream. The problem is that stringstream seems to totally screw up my programs input. Is it somehow using a shared static buffer? I really do not know what is going on and I am getting totally frustrated.

If someone wants to check it out, download the entire test project from here (4 KB zip)[^] and try it out. comment out the #define USE_STRSTREAM line in the header and see the difference in the output. The really weird stuff happens in the make() member function when trying to read the va_list variables.

Any help would be greatly appreciated.

[EDIT]
I any one is interested in making this a joint project, I do not mind co-authoring the article with someone and sharing the credit. The main thing for me is getting this to work.
[/EDIT]



"You're obviously a superstar." - Christian Graus about me - 12 Feb '03

"Obviously ???  You're definitely a superstar!!!" - mYkel - 21 Jun '04

"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05

Within you lies the power for good - Use it!

-- modified at 15:51 Friday 10th February, 2006
AnswerRe: I really do hate string streams Pin
Jörgen Sigvardsson10-Feb-06 11:25
Jörgen Sigvardsson10-Feb-06 11:25 
AnswerRe: I really do hate string streams Pin
Jörgen Sigvardsson10-Feb-06 11:37
Jörgen Sigvardsson10-Feb-06 11:37 
GeneralRe: I really do hate string streams Pin
PJ Arends10-Feb-06 12:04
professionalPJ Arends10-Feb-06 12:04 
GeneralRe: I really do hate string streams Pin
Jörgen Sigvardsson10-Feb-06 12:15
Jörgen Sigvardsson10-Feb-06 12:15 
GeneralRe: I really do hate string streams Pin
PJ Arends10-Feb-06 12:22
professionalPJ Arends10-Feb-06 12:22 
QuestionAPI to enable/disable Windows SP2 Firewall on a given connection? Pin
Carl Mirabel10-Feb-06 9:41
Carl Mirabel10-Feb-06 9:41 
AnswerRe: API to enable/disable Windows SP2 Firewall on a given connection? Pin
Blake Miller13-Feb-06 4:12
Blake Miller13-Feb-06 4:12 
Questioncreating a window... Pin
Peter Charlesworth10-Feb-06 8:51
Peter Charlesworth10-Feb-06 8:51 
Answercreating a window... Pin
Peter Charlesworth10-Feb-06 8:57
Peter Charlesworth10-Feb-06 8:57 
GeneralRe: creating a window... Pin
Peter Charlesworth10-Feb-06 8:59
Peter Charlesworth10-Feb-06 8:59 
GeneralRe: creating a window... Pin
David Crow10-Feb-06 9:15
David Crow10-Feb-06 9:15 
GeneralRe: creating a window... Pin
Peter Charlesworth10-Feb-06 10:05
Peter Charlesworth10-Feb-06 10:05 
AnswerRe: creating a window... Pin
Michael Dunn10-Feb-06 11:09
sitebuilderMichael Dunn10-Feb-06 11:09 
QuestionCListView question Pin
RobJones10-Feb-06 8:22
RobJones10-Feb-06 8:22 
AnswerRe: CListView question Pin
David Crow10-Feb-06 9:19
David Crow10-Feb-06 9:19 
GeneralRe: CListView question Pin
RobJones10-Feb-06 9:27
RobJones10-Feb-06 9:27 
QuestionImmediate Display of Edit Box Pin
jon_fallon10-Feb-06 8:19
jon_fallon10-Feb-06 8:19 

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.