无法创建wchar_t数组 [英] Unable to create an array of wchar_t

查看:88
本文介绍了无法创建wchar_t数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,我有一个wchar_t数组:

In my code I have an array of wchar_t:

wchar_t paths [6] = {L"C:\\Program Files\\SomeAppsSuiteFolder1", L"C:\\Program Files\\SomeAppsSuiteFolder2", L"C:\\Program Files (x86)\\SomeAppsSuiteFolder1", L"C:\\Program Files (x86)\\SomeAppsSuiteFolder2", L"C:\\SomeAppsSuiteFolder1", L"C:\\SomeAppsSuiteFolder2"};

稍后我将中的数组用于循环。问题是,对于这一行,我得到以下错误:

Later on I use the array in for loop. The problem is, that for this line I get following errors:

error: too many initializers for 'wchar_t [6]'
error: initializer-string for array of chars is too long [-fpermissive]

更多,在 for 循环中,我有 if 这样的条件:

What's more, in for loop I have if conditional like this one:

if(GetFileAttributesW(paths[i])!=INVALID_FILE_ATTRIBUTES) {...}

同样,我在这里遇到错误:

And, again, I get an error here:

error: invalid conversion from 'wchar_t' to 'LPCWSTR {aka const wchar_t*}' [-fpermissive]

足够奇怪,使用类似代码可以在几个月前正确编译...是什么问题?

Strange enough, similar code used to compile correctly some months ago... What's the problem?

推荐答案

您需要

const wchar_t* paths[6] = ....

这篇关于无法创建wchar_t数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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