?
Solved

Converting data between wchar_t & LPTSTR

Posted on 2000-04-27
3
Medium Priority
?
823 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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";
   mbstowcs(wc,lpt,16);
   wcstombs(res,wc,16);  
   cout<<res<<endl;
}


0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

752 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