I have been working now on a project based on DirectX and I am struggling with something. Though the DirectX SDK relies heavily on Windows data types like LPSTR, LPCSTR, ... I have been using for my own classes std::string which was quite easy to work with, but it looks strange to mix both ways of handling strings. Although this is a vague question, what do you suggest - should I work with the strings or with the Windows pointers for different string types to keep some consistency?
LPSTR is just an alias for char* and LCPSTR is an alias for const char*, so your question actually sounds like "Should I use C++ strings or C strings?"
Well, C++ std::string has a member function called c_str() (or the equivalent data() function for STL compatibility) that returns a (non-modifiable) C string. So any time a function accepts an LPCTSTR, you can provide the output of c_str() as an argument.
I suggest you working with C++ std::string whenever you can, it is safer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With