C语言指针问题 这程序怎么错了
# 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("请输入两个整数
");
scanf("%a %b",&a,&b);
exchange(&a,&b);
printf("a=%d,b=%d
",a,b);
return 0;
}
wuye11****** 2013-05-04 01:29:12
你犯了严重的错误
main函数中的
scanf(“%a %b)啥意思啊...........你读英文字母啦,,,,应该是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("请输入两个整数
");
scanf("%d %d",&a,&b);
exchange(&a,&b);
printf("a=%d,b=%d ",a,b);
return 0;
}
低级错误不能犯啊。
lclyx1****** 2014-07-31 10:23:15 1 楼