char * []是否可以转换为const char * []? [英] Is char*[] convertible to const char*[]?

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

问题描述

GCC 3.3和MSVS 6.0没有问题将char * []转换为const

char * [](甚至不是警告),但是MS的WinCE编译器生成了一个

错误抱怨说这是不可能的。 MS'的WinCE编译器确实允许从char * []到const char **的转换。


我对什么是感兴趣标准会说这个。 (我没有

有副本。)


非常感谢,


Kevin

GCC 3.3 and MSVS 6.0 have no problem converting char*[] to const
char*[] (not even a warning), but MS''s WinCE compiler generated an
error complained that this was not possible. MS''s WinCE compiler did
allow a conversion from char*[] to const char** though.

I''m interested in what the standard would say about this. (I don''t
have a copy.)

Many thanks,

Kevin

推荐答案

有一些关系:

http://groups.google.com/group/comp .... e9846578e62750

there are some conches:

http://groups.google.com/group/comp....e9846578e62750


我知道将char *转换为const char *就好了。问题

我正在使用字符串数组:" char * []" toconst char * []。我公司使用的

参数解析库指定const char * []

,因为它不会更改命令行参数。但是大多数人都把主要写成int main(int argc,char * argv [])。


有些编译器将argc转换为 const char * []",但其他人似乎无法支付
。什么是正确的?

I know that converting char* to const char* is just fine. The problem
I''m having is with arrays of strings: "char*[]" to "const char*[]". An
argument parsing library my company uses specifies "const char*[]"
because it does not change the command line parameters. But most
people write main as "int main(int argc, char*argv[])".

Some compilers convert argc to "const char*[]", but others seem
incapable. What''s correct?


ke ** ****** @motioneng.com 写道:
我知道将char *转换为const char *就好了。我遇到的问题是字符串数组:" char * []" toconst char * []。我公司使用的
参数解析库指定const char * []
因为它不会更改命令行参数。但大多数人将main写为int main(int argc,char * argv [])。

有些编译器将argc转换为const char * [],但其他人似乎无能为力。什么是正确的?
I know that converting char* to const char* is just fine. The problem
I''m having is with arrays of strings: "char*[]" to "const char*[]". An
argument parsing library my company uses specifies "const char*[]"
because it does not change the command line parameters. But most
people write main as "int main(int argc, char*argv[])".

Some compilers convert argc to "const char*[]", but others seem
incapable. What''s correct?



放慢凯文的速度,看看你在写什么。鉴于..


int main(int argc,char * argv [])


...编译器不能转换为argc at所有。你似乎想要将

的第二个参数限定为main ...


const char * argv []


......但这不是你的电话。标准说所有这些东西都是可写的。

我认为写入它可能是一个坏主意但它是合法的。


-

Joe Wright

所有东西都应尽可能简单,但并不简单。

--- Albert Einstein - -


Slow down Kevin, and read what you''re writing. Given..

int main(int argc, char *argv[])

...compilers don''t convert argc at all. You seem to want to qualify the
second argument to main as..

const char *argv[]

...but it''s not your call. The Standard says all that stuff is writable.
I think it''s probably a bad idea to write to it but it is legal.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---


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

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