473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

ATS
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?

Nov 17 '05 #1
6 3074
ATS wrote:
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
Nov 17 '05 #2
ATS wrote:
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
Nov 17 '05 #3
Have you seen this article?
http://www.codeproject.com/csharp/CsScanf.asp

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"ATS" <AT*@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
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?

Nov 17 '05 #4


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

Nov 17 '05 #5
ATS
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.
Nov 17 '05 #6
ATS wrote:
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
Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Smith | last post by:
Hi all, I have a char buff which contains "1234 ABCD 5678". I can't remember what function I used before to parse the string into individual variables. It was something like this: ...
21
by: pramod | last post by:
Two different platforms communicate over protocols which consist of functions and arguments in ascii form. System might be little endian/big endian. It is possible to format string using sprintf...
1
by: jimjim | last post by:
Hello, I was wondering about the implications of giving as an argument to sprintf a different data type from the one specified in the format argument. This type of question along with some...
0
by: ATS | last post by:
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,...
5
by: tjay | last post by:
Hi. I wrote some code using sprintf and atof to store a double as a string of fixed length and to convert it back to a double variable. The string is stored in a char buffer global variable. I'm...
19
by: Carson | last post by:
Is it possible to remove the dashes in a social security number using sprintf? If so what would the syntax look like? If sprintf won't do this is there a C function that will?
66
by: gyan | last post by:
Hi All, I am using sprintf and getting starnge output in following case char temp_rn; memset(temp_rn,'\0',12); sprintf(temp_rn,"0%s",temp_rn); the final value in temp_rn is 00 how it...
2
by: Martin Manns | last post by:
Hi, I am experiencing some trouble with gmpy v1.01. Multiplying an mpq with inf results in a floating point exception that exits python. Has this already been fixed in newer gmpy versions? ~...
12
by: sas | last post by:
hi, i need that because the path functions for windows, like PathAppend and PathRemoveFileExt accept a writable zero terminated char*, but i didn't find that for std::string, with CString, i...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.