Converting data between wchar_t & LPTSTR

Posted on 2000-04-27
Medium Priority
Last Modified: 2013-11-20
how can I convert :
LPTSTR lpt = "tthtri"


wchar_t wc = L"tthtri"

already use mbstowcs() but the value is different
Question by:ahTri
  • 2
LVL 15

Expert Comment

ID: 2754522
LPTSTR is defined as LPWSTR (or wchar_t*) when UNICODE is defined.

LPTSTR is defined as LPSTR (or char*) when UNICODE is NOT defined.

>>already use mbstowcs() but the value is different

What do you mean?

mbstowcs()/wcstombs() work fine.


Author Comment

ID: 2754570
yeah sorry

wchar_t * wc;
LPTSTR lpt = "tthtri";

if I use mbstowcs() to convert lpt to wc, when I convert back to string it become "t22222"

can you give me the code that convert it please

LVL 15

Accepted Solution

NickRepin earned 200 total points
ID: 2754981
#include <windows.h>
#include <iostream.h>
#include <tchar.h>
#include <string.h>

void main(void)

   wchar_t wc[16];
   TCHAR res[16];
   LPTSTR lpt = "tthtri";


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question