473,396 Members | 1,771 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,396 software developers and data experts.

So many string types!

Hello, All!

Mercy me for a stupid question. I'm just newby.
Which type or class should I use for a comfortable strings manipulation,
namely for setting a first parameter for the fopen() function?
My first try was a using of the CHString class. But the compiler
complains that it can not convert CHString to LPSTR.
I do not wish to use fixed size TCHAR chVar[SIZE] arrays. Is it possible
to workaround its explicit using?
If yes, how?

Thanks in advance Illia Baidakov.
Jul 21 '05 #1
2 1417
"Illia Baidakov" <il***@newchem.ru> wrote in
news:co**********@e22.peterstar.ru...
Hello, All!

Mercy me for a stupid question. I'm just newby.
Which type or class should I use for a comfortable strings manipulation,
namely for setting a first parameter for the fopen() function?
My first try was a using of the CHString class. But the compiler
complains that it can not convert CHString to LPSTR.
I do not wish to use fixed size TCHAR chVar[SIZE] arrays. Is it possible
to workaround its explicit using?
If yes, how?


I guess you are using C++?

This is not a .NET-Problem, actually .NET tries to solve the problem: the
other .NET-languages only have one string type (the .NET-string type). C++
has to support all the other ones for backward compatibility. (That should
explain why you didn't get many answers in a dotnet.general ng).

AFAIK fopen expects a const char*, or (unicode) fwopen const wchar_t*. Every
string class I know has a conversion to one of these types. Unfortunately I
don't know CHString. I know MFC's CString (which can implicitly be converted
to a const TCHAR*), and STL's std::string class (which has a const
c_str()-member function that supports this conversion). Maybe you should
look at this CHString's header file to find out the proper conversion.

Niki
Jul 21 '05 #2
> I guess you are using C++?

Yes, I do.
This is not a .NET-Problem, actually .NET tries to solve the problem: the other .NET-languages only have one string type (the .NET-string type). C++ has to support all the other ones for backward compatibility. (That should explain why you didn't get many answers in a dotnet.general ng).

AFAIK fopen expects a const char*, or (unicode) fwopen const wchar_t*. Every string class I know has a conversion to one of these types. Unfortunately I don't know CHString. I know MFC's CString (which can implicitly be converted to a const TCHAR*), and STL's std::string class (which has a const
c_str()-member function that supports this conversion). Maybe you should look at this CHString's header file to find out the proper conversion.


Now I'm working with the CString. Just my first difficult was, as I
undestood, that MSDN contains an explaining for a current class's
methods, not for the parent's ones. Now I know how to solve this problem.

Thank you!

Illia.
Jul 21 '05 #3

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

Similar topics

7
by: Kamilche | last post by:
I want to convert a dict into string form, then back again. After discovering that eval is insecure, I wrote some code to roll a Python object, dict, tuple, or list into a string. I've posted it...
2
by: Thomas Matthews | last post by:
Hi, I'm working with Borland C++ Builder 6.2. My project uses the std::string class. However, Borland in its infinite wisdom has its own string class, AnsiString. To make my life easier, I...
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
6
by: comp.lang.php | last post by:
I'm involved in a rather nasty debate involving a strange issue (whereby the exasperated tell me to RTFM even after my having done so), where this is insanely possible: print_r(is_int('1'));...
4
by: haitao.song | last post by:
Hi, As it is always stated that value type is allocated on stack, while reference types are on managed heap. How about the struct with string members? stuct A { string str; } String type is...
94
by: smnoff | last post by:
I have searched the internet for malloc and dynamic malloc; however, I still don't know or readily see what is general way to allocate memory to char * variable that I want to assign the substring...
26
by: Neville Lang | last post by:
Hi all, I am having a memory blank at the moment. I have been writing in C# for a number of years and now need to do something in VB.NET, so forgive me such a primitive question. In C#, I...
3
by: psbasha | last post by:
Hi , When ever we read any data from file ,we read as a single line string ,and we convert the respective field data available in that string based on the data type ( say int,float ). ...
21
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
4
by: =?Utf-8?B?ZmFpcnl2b2ljZQ==?= | last post by:
Hi, I want to ask some basic question about the string type. When compiling the unsafe code: --------- string a = "wori"; string* b = &a; --------- it pops up errors saying both 'string*b' and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.