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?
Carl Daniel [VC++ MVP] - 11 Jul 2005 22:24 GMT
> INF: Has anyone made a CString, sprintf, and sscanf for .NET?
>
[quoted text clipped - 15 lines]
> 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
[quoted text clipped - 3 lines]
> 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
Nishant Sivakumar - 12 Jul 2005 05:00 GMT
Have you seen this article?
http://www.codeproject.com/csharp/CsScanf.asp

Signature
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
> INF: Has anyone made a CString, sprintf, and sscanf for .NET?
>
[quoted text clipped - 25 lines]
> has anyone by chance made one already? How about the sprintf and sscanf
> functions?
adebaene@club-internet.fr - 12 Jul 2005 13:20 GMT
ATS a écrit :
> INF: Has anyone made a CString, sprintf, and sscanf for .NET?
>
[quoted text clipped - 3 lines]
> 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
ATS - 12 Jul 2005 13:52 GMT
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.
Carl Daniel [VC++ MVP] - 12 Jul 2005 14:57 GMT
> 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.
Do it yourself -
http://lab.msdn.microsoft.com/productfeedback
-cd