Solved

Converting data between wchar_t & LPTSTR

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

to/from

wchar_t wc = L"tthtri"

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

Expert Comment

by:NickRepin
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.

0
 

Author Comment

by:ahTri
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

0
 
LVL 15

Accepted Solution

by:
NickRepin earned 50 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";
   mbstowcs(wc,lpt,16);
   wcstombs(res,wc,16);  
   cout<<res<<endl;
}


0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 92
Folder Comparison 12 54
pre4 challenge 19 99
EvenOdd challenge 10 105
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now