CString in non-MFC app?
Hya
I've based my app on one of the tutorials in the SDK and now I want to use the CString class. However, when I include the class
( #include <cstring> )
and create a CString variable the compiler says it doesn't recognise the variable type.
How do I sort this out? Should I use string instead? If I should could anyone tell me how to read each character from a string variable. I know how to do it with a CString.
Thanks
Matt
when you include cstring, you are actually including string.h, which is not what you want.
However, if you are creating a non-MFC app, you should probably use the STL string class, which is in the string (not string.h) header file. Then, instead of "CString mystring", you would use "std::string mystring".
The STL string class has members similar to those in CString.
However, if you are creating a non-MFC app, you should probably use the STL string class, which is in the string (not string.h) header file. Then, instead of "CString mystring", you would use "std::string mystring".
The STL string class has members similar to those in CString.
Quote:Original post by de_mattstd::string presents an array-like interface (operator[]) for unchecked element access and the at() method for range-bounded access.
...could anyone tell me how to read each character from a string variable.
MFC's CSring requires certain additional header files to introduce fundamental types, though it should include those itself. It most likely also requires certain environment variables that are not set by default. It's not a particularly good string class, anyway.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement