printf("%s \ n",__ FILE__); / *为什么选择SIGSEGV? * / [英] printf("%s\n", __FILE__); /* why SIGSEGV? */

查看:58
本文介绍了printf("%s \ n",__ FILE__); / *为什么选择SIGSEGV? * /的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么以下语句转储核心(分段错误)?


printf("%s \ n",__ FILE__);

why the following statement dumps the core(Segmentation fault)?

printf("%s\n", __FILE__);

推荐答案

" v4vijayakumar" < V4 *********** @ yahoo.com>写道:
"v4vijayakumar" <v4***********@yahoo.com> writes:
为什么以下语句转储核心(分段错误)?

printf("%s \ n",__ FILE __);
why the following statement dumps the core(Segmentation fault)?

printf("%s\n", __FILE__);




也许是因为它不是完整C程序的一部分。 (如果是的话,

大概你会把它展示给我们。)


或者前一行可能将printf定义为宏。


或许你关闭stdout。


如果你想要实际答案而不是猜测,请向我们展示一个完整的

计划。如果这是一个小测验,而不是一个实际的问题,那么请你这么说。


-

Keith Thompson(The_Other_Keith) ks***@mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。



Perhaps because it''s not part of a complete C program. (If it were,
presumably you would have shown it to us.)

Or maybe the previous line defines printf as a macro.

Or maybe you closed stdout.

If you want actual answers rather than guesses, show us a complete
program. If this is a quiz rather than an actual problem you''re
having, please say so.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.




Keith Thompson写道:

Keith Thompson wrote:
" v4vijayakumar" < V4 *********** @ yahoo.com>写道:
"v4vijayakumar" <v4***********@yahoo.com> writes:
为什么以下语句转储核心(分段错误)?

printf("%s \ n",__ FILE __);
why the following statement dumps the core(Segmentation fault)?

printf("%s\n", __FILE__);



也许是因为它不是完整的C程序的一部分。 (如果是的话,
大概你会把它展示给我们。)

或许前一行将printf定义为一个宏。

或许你关闭了stdout。

如果你想要实际的答案而不是猜测,请向我们展示一个完整的
程序。如果这是一个小测验而不是你遇到的实际问题,请说出来。

-
Keith Thompson(The_Other_Keith) ks *** @ mib.org < http://www.ghoti.net/~kst>
圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>
我们必须做点什么。这是事情。因此,我们必须这样做。



Perhaps because it''s not part of a complete C program. (If it were,
presumably you would have shown it to us.)

Or maybe the previous line defines printf as a macro.

Or maybe you closed stdout.

If you want actual answers rather than guesses, show us a complete
program. If this is a quiz rather than an actual problem you''re
having, please say so.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.




抱歉。这是完整的程序和样本运行。


#cat test.c

#include< stdio.h>


int main()

{

printf("%s\ n",__ FILE __);

printf(" ;%s \ n",_ _ _ _ _ _ _ ;;

printf("%s \ n",__ func__);


返回0;

}


#cc test.c

#。/ a.out

test.c < br $>
分段错误(核心转储)





sorry. Here is the complete program and sample run.

#cat test.c
#include <stdio.h>

int main()
{
printf("%s\n", __FILE__);
printf("%s\n", __LINE__);
printf("%s\n", __func__);

return 0;
}

#cc test.c
#./a.out
test.c
Segmentation fault (core dumped)
#


Keith Thompson< ks *** @ mib.org>写道:
Keith Thompson <ks***@mib.org> wrote:
" v4vijayakumar" < V4 *********** @ yahoo.com>写道:
"v4vijayakumar" <v4***********@yahoo.com> writes:
为什么以下语句转储核心(分段错误)?

printf("%s \ n",__ FILE __);
why the following statement dumps the core(Segmentation fault)?

printf("%s\n", __FILE__);


也许是因为它不是完整的C程序的一部分。 (如果是的话,
大概你会把它展示给我们。)

Perhaps because it''s not part of a complete C program. (If it were,
presumably you would have shown it to us.)




[...]


下一个陈述必须可能是


printf("%s\ n",__ LINE__);


; - )



[...]

Must likely the next statement is something like

printf("%s\n",__LINE__);

;-)


这篇关于printf(&quot;%s \ n&quot;,__ FILE__); / *为什么选择SIGSEGV? * /的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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