a*n
3 楼
without the code, how can others help you? BTW, I am not an expert...
But for example, Linux with gcc deals with string constant differently
with other unix platforms. This is an example which core dumped on Linux
but not on others:
/>cat test.c
#include
#include
#include
int main()
{
char * p = "hello";
*p='p';
printf("%s\n", p);
return 0;
}
/Tru64Unix>cc -V
Compaq C V6.3-025 on Compaq Tru64 UNIX V5.1 (Rev. 732)
【在 d*******e 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 是在程序返回的时候出错。
: 会是为啥?
But for example, Linux with gcc deals with string constant differently
with other unix platforms. This is an example which core dumped on Linux
but not on others:
/>cat test.c
#include
#include
#include
int main()
{
char * p = "hello";
*p='p';
printf("%s\n", p);
return 0;
}
/Tru64Unix>cc -V
Compaq C V6.3-025 on Compaq Tru64 UNIX V5.1 (Rev. 732)
【在 d*******e 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 是在程序返回的时候出错。
: 会是为啥?
o*v
4 楼
这code是合法但不合理的样子......
各个cc的实现不一样吧.
【在 a**n 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: without the code, how can others help you? BTW, I am not an expert...
: But for example, Linux with gcc deals with string constant differently
: with other unix platforms. This is an example which core dumped on Linux
: but not on others:
: />cat test.c
: #include
: #include
: #include
: int main()
: {
各个cc的实现不一样吧.
【在 a**n 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: without the code, how can others help you? BTW, I am not an expert...
: But for example, Linux with gcc deals with string constant differently
: with other unix platforms. This is an example which core dumped on Linux
: but not on others:
: />cat test.c
: #include
: #include
: #include
: int main()
: {
t*c
6 楼
why this one does not work for gcc?
or more specifically, if I change char *p to char p[], it works fine.
any particular reason for this?
【在 a**n 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: without the code, how can others help you? BTW, I am not an expert...
: But for example, Linux with gcc deals with string constant differently
: with other unix platforms. This is an example which core dumped on Linux
: but not on others:
: />cat test.c
: #include
: #include
: #include
: int main()
: {
or more specifically, if I change char *p to char p[], it works fine.
any particular reason for this?
【在 a**n 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: without the code, how can others help you? BTW, I am not an expert...
: But for example, Linux with gcc deals with string constant differently
: with other unix platforms. This is an example which core dumped on Linux
: but not on others:
: />cat test.c
: #include
: #include
: #include
: int main()
: {
a*n
7 楼
if you define char *p = "hello";
then it mean p pointer to a string literal, which is const, and you are
not supposed to change it. You can refer C++ primer or any other book
for this.
If you define it as char p[], it is a different story.
【在 t**c 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: why this one does not work for gcc?
: or more specifically, if I change char *p to char p[], it works fine.
: any particular reason for this?
then it mean p pointer to a string literal, which is const, and you are
not supposed to change it. You can refer C++ primer or any other book
for this.
If you define it as char p[], it is a different story.
【在 t**c 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: why this one does not work for gcc?
: or more specifically, if I change char *p to char p[], it works fine.
: any particular reason for this?
t*c
8 楼
that's what I suspect, but just don't know the implementation details.
thanks.
【在 a**n 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: if you define char *p = "hello";
: then it mean p pointer to a string literal, which is const, and you are
: not supposed to change it. You can refer C++ primer or any other book
: for this.
: If you define it as char p[], it is a different story.
thanks.
【在 a**n 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: if you define char *p = "hello";
: then it mean p pointer to a string literal, which is const, and you are
: not supposed to change it. You can refer C++ primer or any other book
: for this.
: If you define it as char p[], it is a different story.
相关阅读
[转载] sed question什么命令可以查看sockets端口的占用情况?(null)thxHow to see line number in EmacsRe: sony notebook , good deal?rsh hangs on background jobhow to compress several file under unix[转载] 大家推荐几个站点可以迅速了解Sun Os命令的如何?fileIDC++5.0的初级问题how to install printer in Solaris 2.5?如何在提示符前显示目录,就想DOS那样.X Window求助Anybody downloaded solaris 8 for sparc successfully?Cannot change passwordqutstion: upgrade to solaris 2.8 , cdrom share..(continue)free list 是什么意思?how to rsh NT from unixRe: 如何forward email?Re: sparc 20 would be under $50 soon with the speed of price drop of e.so文件