By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

MC++ String::Format?

P: n/a
The first three of these statements work. The fourth doesn't.

String::Format("{0}{0}{0}{0}", S"");
String::Format("{0}{1}{0}{0}", S"", S"");
String::Format("{0}{1}{2}{0}", S"", S"", S"");
String::Format("{0}{1}{2}{3}", S"", S"", S"", S"");

Question #1: Why?

Question #2: What is the simplest way to get this to work. I would
prefer to keep this statement on one line as opposed to separate
statements to declare, populate, and use a parameter array variable.
Nov 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"Tommy Vercetti" <ve*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
The first three of these statements work. The fourth doesn't.

String::Format("{0}{0}{0}{0}", S"");
String::Format("{0}{1}{0}{0}", S"", S"");
String::Format("{0}{1}{2}{0}", S"", S"", S"");
String::Format("{0}{1}{2}{3}", S"", S"", S"", S"");

Question #1: Why?
Because only the first 3 overloads are declared and defined.

Perhaps you meant to ask why that decision was made. The
threshold had to be established somewhere. Where it is set
now seems reasonable but to know for sure whether it is
optimal would require looking at a lot of code and making
an arbitrary decision about the code space versus execution
time tradeoff.
Question #2: What is the simplest way to get this to work. I would prefer to keep this statement on one line as opposed to
separate statements to declare, populate, and use a parameter array variable.


Your dispreferred method is the only way if you insist on a
single call to String::Format(). If you love "single line" enough,
you can concatenate the results of some calls that observe the
3 parameter limitation. Personally, I would consider that to
be honoring a fetish rather than having any real merit.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.
Nov 17 '05 #2

P: n/a
Larry Brasfield wrote:
Your dispreferred method is the only way if you insist on a
single call to String::Format(). If you love "single line" enough,
you can concatenate the results of some calls that observe the
3 parameter limitation. Personally, I would consider that to
be honoring a fetish rather than having any real merit.


It would be nice if this just worked; after all C has had sprintf and
varargs support for ages. But you are right; this isn't a huge deal by
itself and is fairly easily worked around. The variety of MC++ bugs and
issues that I've had to deal with in the last 24 hours have just made me
a little inpatient.
Nov 17 '05 #3

P: n/a
"Tommy Vercetti" <ve*********@hotmail.com> wrote in message
news:ut**************@TK2MSFTNGP12.phx.gbl...
It would be nice if this just worked; after all C has had sprintf and
varargs support for ages. But you are right; this isn't a huge deal by
itself and is fairly easily worked around. The variety of MC++ bugs and
issues that I've had to deal with in the last 24 hours have just made me a
little inpatient.


It just works in VC++ 2005 when using the new C++/CLI syntax.

-cd
Nov 17 '05 #4

P: n/a
On Thu, 17 Feb 2005 16:20:44 -0600, Tommy Vercetti
<ve*********@hotmail.com> wrote:
Larry Brasfield wrote:
Your dispreferred method is the only way if you insist on a
single call to String::Format(). If you love "single line" enough,
you can concatenate the results of some calls that observe the
3 parameter limitation. Personally, I would consider that to
be honoring a fetish rather than having any real merit.


It would be nice if this just worked; after all C has had sprintf and
varargs support for ages. But you are right; this isn't a huge deal by
itself and is fairly easily worked around. The variety of MC++ bugs and
issues that I've had to deal with in the last 24 hours have just made me
a little inpatient.


I haven't been an inpatient since my appendectomy. :)

But I do agree, I find MFC quite infuriating and much more difficult
to code and debug than regular Win32 API coding in C (and C++ where
appropriate).

--
Sev
Nov 17 '05 #5

P: n/a
Severian wrote:
But I do agree, I find MFC quite infuriating and much more difficult
to code and debug than regular Win32 API coding in C (and C++ where
appropriate).


What has this got to do with the original poster's question, which
relates to the .NET framework API?

--
Gerhard Menzl

#dogma int main ()

Humans may reply by replacing the thermal post part of my e-mail address
with "kapsch" and the top level domain part with "net".
Nov 17 '05 #6

P: n/a
On Fri, 18 Feb 2005 09:02:44 +0100, Gerhard Menzl
<ge***********@hotmail.com> wrote:
Severian wrote:
But I do agree, I find MFC quite infuriating and much more difficult
to code and debug than regular Win32 API coding in C (and C++ where
appropriate).


What has this got to do with the original poster's question, which
relates to the .NET framework API?


Perhaps you missed the OP's comment in his response:

"The variety of MC++ bugs and issues that I've had to deal with in the
last 24 hours have just made me a little inpatient."

And perhaps I misread MC++ as MFC, too!

--
Sev
Nov 17 '05 #7

P: n/a
Tommy Vercetti wrote:
Larry Brasfield wrote:
Your dispreferred method is the only way if you insist on a
single call to String::Format(). If you love "single line" enough,
you can concatenate the results of some calls that observe the
3 parameter limitation. Personally, I would consider that to
be honoring a fetish rather than having any real merit.
It would be nice if this just worked; after all C has had sprintf and
varargs support for ages.

Yes, the most error prone and dangerous way for string formatting!
But you are right; this isn't a huge deal by
itself and is fairly easily worked around.

Using StringBuilder may be an option for building complex strings.

Arnaud
MVP - VC
Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.