TCHAR* and LPTSTR
-
I also declared a struct and put a member inside with the same name and it's still working.
struct
{
LPTSTR shi502_netname;
}p;p.shi502_netname = _T("test");
LPTSTR h = p.shi502_netname ;
TCHAR* var = h;
cout<Here is the code. It's working.:^)
Jesus Loves:rose:
--Owner Drawn:rose:
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord:rose: -
I have edited the struct, its not a normal struct (typedef) typedef struct { LPTSTR shi502_netname; }p; p.shi502_netname = _T("test"); LPTSTR h = p.shi502_netname ; TCHAR* var = h;cout<
typedef struct
{
LPTSTR shi502_netname;
}p;Did you declare a variable of type p.
p p1; //don't forget this
p1.shi502_netname = _T("test");
LPTSTR h = p1.shi502_netname ;
TCHAR* var = h;
cout<
It still works fine.Jesus Loves:rose:
--Owner Drawn:rose:
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord:rose: -
typedef struct
{
LPTSTR shi502_netname;
}p;Did you declare a variable of type p.
p p1; //don't forget this
p1.shi502_netname = _T("test");
LPTSTR h = p1.shi502_netname ;
TCHAR* var = h;
cout<
It still works fine.Jesus Loves:rose:
--Owner Drawn:rose:
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord:rose: -
Yes i do. you did not declare yours as *p look at my definition of my struct below typedef struct { LPTSTR shi502_netname; }*p; p p1; //don't forget thisp1.shi502_netname = _T("test");LPTSTR h = p1.shi502_netname ;TCHAR* var = h;cout<
Aha here is the problem...
typedef struct
{
LPTSTR shi502_netname;
} ap,*p;ap a;
p p1 = &a;
p1->shi502_netname = _T("test");
LPTSTR h = p1->shi502_netname ;
TCHAR* var = h;
cout<It works with the modifications that I made. You have to make another
typedef
along with*p
i.eap
. If you don't what are you going to assign to a variable of typep
.p
needs an address of a struct of it's own type.An advice: Please provide some meaningful names for variables and specially typedefs.
Jesus Loves:rose:
--Owner Drawn:rose:
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord:rose: -
Aha here is the problem...
typedef struct
{
LPTSTR shi502_netname;
} ap,*p;ap a;
p p1 = &a;
p1->shi502_netname = _T("test");
LPTSTR h = p1->shi502_netname ;
TCHAR* var = h;
cout<It works with the modifications that I made. You have to make another
typedef
along with*p
i.eap
. If you don't what are you going to assign to a variable of typep
.p
needs an address of a struct of it's own type.An advice: Please provide some meaningful names for variables and specially typedefs.
Jesus Loves:rose:
--Owner Drawn:rose:
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord:rose:I tried it it did not work the struct that iam using is part of the C++ libraries here it is typedef struct _SHARE_INFO_502 { LPTSTR shi502_netname; DWORD shi502_type; LPTSTR shi502_remark; DWORD shi502_permissions; DWORD shi502_max_uses; DWORD shi502_current_uses; LPTSTR shi502_path; LPTSTR shi502_passwd; DWORD shi502_reserved; PSECURITY_DESCRIPTOR shi502_security_descriptor; } SHARE_INFO_502, *PSHARE_INFO_502, *LPSHARE_INFO_502; And i have to use *PSHARE_INFO_502 as the name of the struct Kelvin Chikomo
-
I tried it it did not work the struct that iam using is part of the C++ libraries here it is typedef struct _SHARE_INFO_502 { LPTSTR shi502_netname; DWORD shi502_type; LPTSTR shi502_remark; DWORD shi502_permissions; DWORD shi502_max_uses; DWORD shi502_current_uses; LPTSTR shi502_path; LPTSTR shi502_passwd; DWORD shi502_reserved; PSECURITY_DESCRIPTOR shi502_security_descriptor; } SHARE_INFO_502, *PSHARE_INFO_502, *LPSHARE_INFO_502; And i have to use *PSHARE_INFO_502 as the name of the struct Kelvin Chikomo
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:
-
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