Link to home
Start Free TrialLog in
Avatar of Chang
Chang

asked on

String to Char[ ]

Is it possible to convert a string into a char array?  I have tried strcpy() and many other functions with no success.
Avatar of V245
V245

Try something like this:

      CString Str = "Test STring";
      char szStr[32];
      strcpy((char*)szStr, LPCTSTR(Str));

CString in an MFC class.  Do you mean the STL string class called "string"?  If not one of those, what do you mean by "string" ?
Avatar of Chang

ASKER

I'm sorry, for not phrasing my question properly.  I thought there might be a way to convert all string types to a char[] type.  I have raised the points for your troubles, sorry.

I want to convert a an LPTSTR to a WCHAR, here are my 2 variables in my program:
WCHAR LPtemp[500];
LPTSTR fName;


ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chang

ASKER

I figured out the problem, it was an extreemly simple solution compared to what I was trying to do.  I do not think the conversion I was trying is even possible.  Your answer did however lead me in the right direction, thank you very much for your help nietod!