So many string types!

  • Thread starter Thread starter Illia Baidakov
  • Start date Start date
I

Illia Baidakov

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.
 
Illia Baidakov said:
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
 
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.
 
Back
Top