无法弄清楚这一点 [英] Can't figure this out
问题描述
各位大家好,
我只是有一点问题,我不知道它是什么:
[gongds @ labtherm] [15:52:28] $ cat test.c
#include< stdio.h>
int main(void)
{
char * s =" CAT";
*(s + 1)='''B'';
printf("%s",s);
返回(0);
}
[gongds @ labtherm] [15:52:32] $ gcc -o test test.c
[gongds @ labtherm] [15:52:40] $ ./test
分段错误(核心倾销)
[gongds @ labtherm] [15:52:42] $
我在这里做错了什么?只是为了获取信息,这个代码是在Windows 98机器上使用GCC在cygwin下编译的。
感谢您的帮助,
干杯!
---
Joseph
cat test.c
#include< stdio.h>
int main(无效)
{
char * s =" CAT";
*(s + 1)=''B'';
printf(" %s",s);
返回(0);
}
[gongds @ labtherm] [15:52 :32]
gcc -o test test.c
[gongds @ labtherm] [15:52:40]
< blockquote> ./ test
分段错误(核心转储)
[gongds @ labtherm] [15:52:42]
Hello everybody,
I just have a little problem, and I just can''t figure out what it is:
[gongds @ labtherm][15:52:28]$ cat test.c
#include <stdio.h>
int main (void)
{
char* s = "CAT";
*(s+1) = ''B'';
printf("%s", s);
return (0);
}
[gongds @ labtherm][15:52:32]$ gcc -o test test.c
[gongds @ labtherm][15:52:40]$ ./test
Segmentation fault (core dumped)
[gongds @ labtherm][15:52:42]$
Just what am I doing wrong here? Just for information this ''code'' was
compiled using GCC under cygwin, on a windows 98 machine.
Thank-you for any help,
Cheers!
---
Joseph
cat test.c
#include <stdio.h>
int main (void)
{
char* s = "CAT";
*(s+1) = ''B'';
printf("%s", s);
return (0);
}
[gongds @ labtherm][15:52:32]
gcc -o test test.c
[gongds @ labtherm][15:52:40]
./test
Segmentation fault (core dumped)
[gongds @ labtherm][15:52:42]
这篇关于无法弄清楚这一点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!