INF: Has anyone made a CString, sprintf, and sscanf for .NET?

G

Guest

INF: Has anyone made a CString, sprintf, and sscanf for .NET?

Please help,

I want to code with PURE .NET (i.e. pure CLR). No MFC, No ATL, no C-Run Time
Library. But I want CString, sprintf, and sscanf. The "String" class in .NET
is completely worthless to me, especially its so called "Format" method. In
fact to just, harp on how "lacking" it is to me, in C++.NET, one can NOT do
this:

String *csTest;
csTest = "Hello";
csTest += "!!!"; // ==> This generates an error...

This generates these compile errors:

error C2297: '+=' : illegal, right operand has type 'const char [4]'
cannot perform pointer arithmetic on __gc pointer 'System::String __gc *'

With that said, PLEASE DO NOT RESPOND TO THIS ISSUE IN REGARDS TO DOING
ANYTHING WITH .NET "String". ACCEPT IT. IT LEAVES A LOT FOR ME TO DESIRE.

So. Before I go down the road to making my own CString class for C++.NET,
has anyone by chance made one already? How about the sprintf and sscanf
functions?
 
C

Carl Daniel [VC++ MVP]

ATS said:
INF: Has anyone made a CString, sprintf, and sscanf for .NET?

Please help,

I want to code with PURE .NET (i.e. pure CLR). No MFC, No ATL, no
C-Run Time Library. But I want CString, sprintf, and sscanf. The
"String" class in .NET is completely worthless to me, especially its
so called "Format" method. In fact to just, harp on how "lacking" it
is to me, in C++.NET, one can NOT do this:

String *csTest;
csTest = "Hello";
csTest += "!!!"; // ==> This generates an error...

This generates these compile errors:

error C2297: '+=' : illegal, right operand has type 'const char [4]'
cannot perform pointer arithmetic on __gc pointer 'System::String
__gc *'

That's a limitation of managed extensions for C++, not a limitation of the
..NET System::String class. MC++ cannot do operator overload resolution for
..NET types because you're dealing with pointers and not objects. The .NET
string class in fact does support what you want, it's just hard to get at
from C++ (but easy and obvious from C#).
With that said, PLEASE DO NOT RESPOND TO THIS ISSUE IN REGARDS TO
DOING ANYTHING WITH .NET "String". ACCEPT IT. IT LEAVES A LOT FOR ME
TO DESIRE.

So. Before I go down the road to making my own CString class for
C++.NET, has anyone by chance made one already? How about the sprintf
and sscanf functions?

Go for it. IMO the .NET string/formatting classes already provide far more
capability that CString/sprintf/sscanf, but YMMV.

-cd
 
A

adebaene

ATS a écrit :
INF: Has anyone made a CString, sprintf, and sscanf for .NET?

Please help,

I want to code with PURE .NET (i.e. pure CLR). No MFC, No ATL, no C-Run Time
Library. But I want CString, sprintf, and sscanf. The "String" class in ..NET
is completely worthless to me, especially its so called "Format" method.

Have you tried System::Text::StringBuilder?
With that said, PLEASE DO NOT RESPOND TO THIS ISSUE IN REGARDS TO DOING
ANYTHING WITH .NET "String". ACCEPT IT. IT LEAVES A LOT FOR ME TO DESIRE.

This kind of position is not generally the good way to receive help on
newsgroups....

Arnaud
MVP - VC
 
G

Guest

Thanks everyone for the reply,

Sadly, no replies helped.

Could someone please forward to Microsoft my "wish" that .NET have a CString
class just like the MFC version, and sprintf and sscanf.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top