类型转换为char []到LPWCH [英] Type casting char [] to LPWCH

查看:305
本文介绍了类型转换为char []到LPWCH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI
我正在尝试打印文件的路径.我收到此错误

HI
I am trying to print the path of file. i am getting this error

Error   1   error C2664: 'GetModuleFileNameW' : cannot convert parameter 2 from 'char [1024]' to 'LPWCH'   



这是简单的代码....我如何在控制台上打印文件路径.我正在使用Visual Studio



Here is the simple code ....how can i print file path on to console . i am using visual studio

#include "stdio.h"
void main()
{
char buf[1024];
	GetModuleFileName(NULL,buf,1024);
	
	printf("%s",buf);
	getch();
}

推荐答案

尝试一下,

Try this,

void main()
{
    TCHAR buf[1024];
	GetModuleFileName(NULL,buf,1024);
	wprintf(_T("%s\n"),buf);
    cout<<buf;
}


使用正在使用Unicode字符集:).

LPWCH是指向宽(两个字节)字符串的指针.

char [1024]是一个单字节字符数组


use are using Unicode Character Set :).

LPWCH is a pointer to a wide (two byte) character string.

char [1024] is an array of single byte characters


谢谢...快速回复... ti有用
Thank you ...for quick reply ... ti worked


这篇关于类型转换为char []到LPWCH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆