d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Convert Char To Lpstr
Add Reply New Topic New Poll
Member
Posts: 27,086
Joined: Mar 7 2008
Gold: 685.00
Sep 24 2013 08:34pm
Code
const int n = 108;
const int n = 108;
char val [10];

Carac = EntierACarac(n);
Val[0] = Carac;
SetDlgItemText(hDlg, IDC_EXIT, Val); //getting "lØ▲¢°~JÎıߦ" instead of "l"

char IntoCha(const int e)
{
char carac;
carac = (char)e;
return carac;
}

Member
Posts: 237
Joined: Aug 6 2011
Gold: 6,026.00
Sep 24 2013 09:55pm
not a conversion problem, you didn't add the null byte at the end of your string

Val[0] = Carac;
Val[1] = 0

All routines in C/C++ that take a char array as input with intent of processing as a string of text need to be null terminated, i.e. add a 0 byte at the end of your text.
Member
Posts: 17,856
Joined: Apr 4 2012
Gold: 59.31
Sep 29 2013 07:45pm
converting seems very complex ....
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll