int main (int argc, char *argv[])
{
int a, b, quo, rest;
void division(int dividendo, int divisor, int *ptr_quociente, int *ptr_resto)
{
*ptr_quociente=dividendo/divisor;
*ptr_resto=dividendo%divisor;
}
if(argc=3)
{
a= atoi(argv[1]);
b= atoi(argv[2]);
division(a,b,&quo,&rest);
printf(" %d and %d \n",quo,rest);
}
else if (argc=1)
do
{
printf("type two int numbers:\n");
scanf("%d %d", &a, &b);
division(a,b,&quo,&rest);
printf(" %d and %d \n",quo,rest);
} while(a!=0);
}
如果我這樣做:爲什麼這種分段錯誤(核心轉儲)??? INT主(INT ARGC,CHAR *的argv [])
./program.c 12 6
它的工作原理,但如果我這樣做:
./program.c
我得到一個分段錯誤,爲什麼呢?
'argc = 3'應該是'argc == 3' –
謝謝!我應該看到它,有點累...... – Bryant2