求救,如何把LPTSTR安全转换为LPCTSTR?

bluecoff 2003-08-27 02:49:11
我把LPTSTR类型数据强制转换为LPCTSTR时,LPCTSTR就为空。如
include<windows.h>
.
.
LPTSTR lp;
LPCTSTR lpc;
.
.
lp="hello"
lpc=lp;
cout<<lpc;

得到的结果是空。
...全文
20 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
bluecoff 2003-08-27
  • 打赏
  • 举报
回复
#include <fstream>
#include <windows.h>
void main(void){
using namespace std;
LPCTSTR dirname;
HANDLE hfind;
WIN32_FIND_DATA fd;
LPWIN32_FIND_DATA pfd;
fd.dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY;
pfd=&fd;
DWORD nbuff;
LPTSTR curpath,str;
if(!GetCurrentDirectory(nbuff,curpath))
{
cout<<"当前目录错误";
return;
}
strcat(curpath,"\\*");
cout<<curpath;
dirname=curpath;
cout << dirname;//这句相当关键,有没有结果完全不同,
不仅dirname结果不同连curpath也不同
}
bluecoff 2003-08-27
  • 打赏
  • 举报
回复
我是用的BC++编译器,确实不行。就是没有这两行

#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
这两行是什么意思?
bcb_alone 2003-08-27
  • 打赏
  • 举报
回复
不可能,我试过了。
#include <windows.h>
#include <iostream>
#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{
using namespace std;
LPTSTR s="hxj";
LPCTSTR t;
t=s;
cout << t;
return 0;
}

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧