LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1983|回复: 2

请问[段错误(core dumped)]是个什么意思?

[复制链接]
发表于 2008-4-17 14:45:06 | 显示全部楼层 |阅读模式
学习C时候,一个书中的例子,我原封不动的抄的.编译成功,但是执行a.out时候,出现错误并返回,错误提示为[段错误(core dumped)].因为书中的那个例子也是在unix环境下编程的,所以我想应该不会是程序的问题.我特别在win下面也做了编译,是成功的.并且可执行.

程序本身很简单,如下:
[code]
#include <stdio.h>

int main(void)
{
   char     c1, c2, c3;
   int      i;
   float    x;
   double   y;

   printf("\n%s\n%s",
      "Input three characters,"
      "an int, a float, and a double:  ");
   scanf("%c%c%c%d%f%lf", &c1, &c2, &c3, &i, &x, &y);
   printf("\nHere is the data that you typed in:\n");
   printf("%3c%3c%3c%5d%17e%17e\n\n", c1, c2, c3, i, x, y);
   return 0;
}
[code]

希望大家帮忙.说下原因和解决办法~~.谢谢

----------------------%<---------------------
补充一下.更有意思的事情发生了.
我把最后那个printf分成2行来写,即:
[code]
printf("%3c%3c%3c%5d\n\n", c1, c2, c3, i);
printf("%17e%17e\n\n", x, y);
[code]

这样就什么事情都没有了.一切正常..真是令人很费解阿~~
发表于 2008-4-18 16:24:01 | 显示全部楼层
printf("\n%s\n%s",
"Input three characters,"
"an int, a float, and a double: ");
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-4-18 20:06:16 | 显示全部楼层
回楼上的,谢谢你.我今天上午也找到了...呵呵...
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表