TCHAR* and LPTSTR
-
Does anybody know how to assign a TCHAR* fromo a LPTSTR. This is my code:
p->shi502_netname ="test"; LPTSTR h =p->shi502_netname ; TCHAR* var = h; cout< output: t when I try to print out h i get the first letter of string pointed to by h; I thing im no accessing the string from the pointer correctly Kelvin Cikomo
This maybe is a stupid question but I have to ask: Are your program using UNICODE? In that case, it's perfectly understandable: The console doesn't want UNICODE, so when your 't' is written to the consol, the console sees a 't', followed by a \0. And since \0 is a string terminator, the output is terminated. Could this be the case here?
-
This maybe is a stupid question but I have to ask: Are your program using UNICODE? In that case, it's perfectly understandable: The console doesn't want UNICODE, so when your 't' is written to the consol, the console sees a 't', followed by a \0. And since \0 is a string terminator, the output is terminated. Could this be the case here?
-
Go ahead it will work.
PSHARE_INFO_502
should take the address of a valid structure of the same type. Then it has to work. Probably like this:SHARE_INFO_502 shInfo;
PSHARE_INFO_502 pShInfo = &shInfo;
Now usepShInfo
as you should.Jesus Loves:rose:
--Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:
I get wrong out puts if i try this. let me just give you part of my code
PSHARE_INFO_502 BufPtr,p; //SHARE_INFO_502 shInfo; //PSHARE_INFO_502 pShInfo = &shInfo; NET_API_STATUS res; LPTSTR lpszServer = NULL; DWORD er=0,tr=0,resume=0, i; //declare server variable lpszServer = lpszArgv[1]; cout<shi502_netname; cout<
-
I am not printing any thing to the console as yet. You can look at the above threads to see my code. Kelvin Chikomo
kelprinc wrote:
I am not printing any thing to the console as yet.
Sure you are. What do you think
cout
is for?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
-
Does anybody know how to assign a TCHAR* fromo a LPTSTR. This is my code:
p->shi502_netname ="test"; LPTSTR h =p->shi502_netname ; TCHAR* var = h; cout< output: t when I try to print out h i get the first letter of string pointed to by h; I thing im no accessing the string from the pointer correctly Kelvin Cikomo
You need to use
wcout
instead ofcout
.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
-
Does anybody know how to assign a TCHAR* fromo a LPTSTR. This is my code:
p->shi502_netname ="test"; LPTSTR h =p->shi502_netname ; TCHAR* var = h; cout< output: t when I try to print out h i get the first letter of string pointed to by h; I thing im no accessing the string from the pointer correctly Kelvin Cikomo
if you are using unicode build then you should use unicode set of apis to work on them. If you really need to work on multibyte string then you may have to use WideCharToMultiByte api to do the convertion.
-Prakash
-
I get wrong out puts if i try this. let me just give you part of my code
PSHARE_INFO_502 BufPtr,p; //SHARE_INFO_502 shInfo; //PSHARE_INFO_502 pShInfo = &shInfo; NET_API_STATUS res; LPTSTR lpszServer = NULL; DWORD er=0,tr=0,resume=0, i; //declare server variable lpszServer = lpszArgv[1]; cout<shi502_netname; cout<
as i can see from here, your real problem is probably not
cout<. I guess that cout statement is a debug output statement. if you want to fix that part, you have to use wcout and it will print properly. Is there any other problem in your code beside printing? * * * -Prakash