我使用gcc編譯器在Ubuntu 14.04 LTS的後續的c程序編譯分割故障(核心轉儲)在C程序
#include<stdio.h>
void main()
{
int *a,*b;
*a=2;
*b=3;
printf("\n printing address.....\n address of a = %d \n address of b = %d \n",a,b);
printf("\n\n printing values ..... \n value of a = %d \n value of b = %d \n",*a,*b);
}
,當我運行上面的程序比我在輸出得到以下
output: Segmentation fault (core dumped)
請建議我在哪裏做錯了。
謝謝
'INT A,B; INT * A =&A,* B =&B;'' – BLUEPIXY
空隙main'是錯誤的,順便說一句。 'main'返回'int'。 – melpomene
**總是**用'gcc -Wall -Weror'編譯你的代碼。這會阻止你犯這樣愚蠢的錯誤。 –