How to convert a char to a CString

Hey,
I am trying to convert a char to a CString, I have tried to use the CString.Format method but didn't work. I have a char(char holder[10]) and I want to see if holder is a certain string, say for instance SeaLevel. Below is the code that I also tried.
1
2
3
4
5
  if(holder == "SeaLevel")
  {
      //do something
  }


Any help with this will be greatly appreciated.

Thanks In Advance
Do you have to use Microsoft's CString class and C++/CLI? Or can you use std::string and real C++ instead?
Last edited on
If holder is char holder[10]; then you need to use

1
2
3
4
  if(0 == strcmp(holder, "SeaLevel"))
  {
      //do something
  }


Are you working with MFC?

Format should work, but you should be able to set a CString to the same value as a char array using operator=

But you should be using the _T() macro when you work with MFC, e.g.

CString msg = _T("Hello world!");

and TCHAR rather than char, e.g.

TCHAR holder[10];

Andy

PS CString is nothing to do with C++/CLI

CString = MFC
System::String = C++/CLI
Last edited on
Andywestken,
Thanks will try. Yes, I am using MFC.
Topic archived. No new replies allowed.