473,320 Members | 2,158 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,320 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 3070
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.