#include <stdio.h>
#include <stdlib.h>
void Block(int function_no,int instrument_no)
{
<span style="white-space:pre"> </span>char *function;
char *instrument;
char *result;
sprintf(function,"%d",function_no);
sprintf(instrument,"%d",instrument_no);
sprintf(result,"%d.%d",function_no,instrument_no);
printf("%s\n",result);
}
int main()
{
Block(3,5);
}
c文件命名为a.c
使用GCC编译器进行编译:gcc a.c -o a.out生成a.out的可执行文件
执行该可执行文件:./a.out
出现以下错误:
a.out[14606]: segfault at 0 ip 0000003e1e689901 sp 00007fff0658cb48 error 6 in libc-2.12.so[3e1e600000+18a000]
</pre><pre name="code" class="html"