C語(yǔ)言指針問(wèn)題 這程序怎么錯(cuò)了
# include<stdio.h>
void exchange(int *a,int*b)
{
int t;
t = *a;
*a = *b;
*b = t;
return;
}
int main(void)
{
int a,b;
printf("請(qǐng)輸入兩個(gè)整數(shù)
");
scanf("%a %b",&a,&b);
exchange(&a,&b);
printf("a=%d,b=%d
",a,b);
return 0;
}
wuye11****** 2013-05-04 01:29:12
你犯了嚴(yán)重的錯(cuò)誤
main函數(shù)中的
scanf(“%a %b)啥意思啊...........你讀英文字母啦,,,,應(yīng)該是scanf(%d%d).....
# include<stdio.h>
void exchange(int *a,int*b)
{
int t;
t = *a;
*a = *b;
*b = t;
}
int main( )
{
int a,b;
printf("請(qǐng)輸入兩個(gè)整數(shù)
");
scanf("%d %d",&a,&b);
exchange(&a,&b);
printf("a=%d,b=%d ",a,b);
return 0;
}
低級(jí)錯(cuò)誤不能犯啊。
lclyx1****** 2014-07-31 10:23:15 1 樓