“CHAR字符串数组”的第一个元素 [英] 1st element of "an array of CHAR strings"

查看:339
本文介绍了“CHAR字符串数组”的第一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int main()

{

const char * arr [] = {" bjarne"," stroustrup"," c ++"} ;

char * parr =& arr;

}


这会产生错误:

[arch @ voodo tc ++ pl] $ g ++ test.cpp

test.cpp:在函数''int main()''中:

test.cpp: 4:错误:无法将''const char *(*)[3]''转换为''char *''

初始化

[arch @ voodo tc + + pl] $

这里有什么问题?

int main()
{
const char* arr[] = {"bjarne", "stroustrup", "c++"};
char* parr = &arr;
}

this gives an error:
[arch@voodo tc++pl]$ g++ test.cpp
test.cpp: In function ''int main()'':
test.cpp:4: error: cannot convert ''const char* (*)[3]'' to ''char*'' in
initialization
[arch@voodo tc++pl]$
what is wrong here ?

推荐答案

g ++ test.cpp

test.cpp:在函数''int main()''中:

test.cpp:4:错误:无法转换''const char *(*)[3]''到''char *''

初始化

[arch @ voodo tc ++ pl]
g++ test.cpp
test.cpp: In function ''int main()'':
test.cpp:4: error: cannot convert ''const char* (*)[3]'' to ''char*'' in
initialization
[arch@voodo tc++pl]




这里有什么问题?


what is wrong here ?


* arnuld:
* arnuld:

int main()

{

const char * arr [] = {" bjarne"," stroustrup"," c ++"};

char * parr =& arr;

}


这给出了一个错误:

[arch @ voodo tc ++ pl]
int main()
{
const char* arr[] = {"bjarne", "stroustrup", "c++"};
char* parr = &arr;
}

this gives an error:
[arch@voodo tc++pl]


这篇关于“CHAR字符串数组”的第一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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