我能得到一些关于以下代码的帮助吗?
int main()
{
char ***dir= new char**[ 256 ];
static char *sDir[2];
static char sDList[2][256];
wstring gResourcePath = L"/home/cri";
for (int i=0; i<2; i++)
{
sDir[i] = sDirList[i];
}
wstring temp1 = gResourcePath + L"/Font";
sprintf( sDList[0], "%ls", temp1.c_str()) ;
wstring temp2 = gResourcePath + L"/CMap";
sprintf( sDList[1], "%ls", temp2.c_str()) ;
*dir= sDir;
for (int i=0; i<2; i++)
{
wcout << dir[ i ] << "\n";
}
return 0;
}
我希望能够从目录中提取元素:
/home/cri/Dir1
/home/cri/Dir2
我得到的输出是:
0x602400
0
我在 Linux 上使用 Eclipse CDT 和 GCC 4.4
最佳答案
wcout << *dirListP[i] << "\n";
只需在wcout
中添加一个*
。没有它,您访问的是 char** 的地址而不是它的值。
关于c++ - 无法从 char 三重指针获取或打印 wstring 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33895791/