Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CString Format method

Status
Not open for further replies.

developer155

Programmer
Jan 21, 2004
512
0
0
US
Can someone please explain or point me to comprehensive source of info on CString::Format. I looked at docs at MSDN, they dont really explain how it works. Like what would this do?
SomeCString.Format ( "%12.0f", Milliseconds );

and

AnotherCStringFormat( "%.1u", "Location" );

what would be the out put and how does it work?

thanks!!!
 
The CString::Format method expects a string in a format identical to what you would give printf or a similar C function. Try doing a Google search for it instead and you should find all you need to know.
 
>I looked at docs at MSDN, they dont really explain how it works

Really?

>Like what would this do?
How about yout write a small app that does that very thing. Set a breakpoint and step into the code to see what is happening.

>what would be the out put
Now, how can you figure that one out?

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
Yes, MSDN has a lot of wisdom about CString (printf like) format specifications. Or take any C book and read printf() samples.
We can say at once that 2nd Format do nothing (useful): it tries to print string literal pointer ("Location") as unsigned int (%u format spec) while precision spec (.1) is not applicable to u specifier and is ignored...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top