通过函数来赋值!!!急急急!!!
怎样将函数fun()中的x,y值写到main函数中的aa及bb中?以下面的调用形式
#include <stdio.h>
void fun(int *a, int *b)
{
int x,y;
x = 5;
y = 6;
a = &x;
b = &y;
}
int main(int argc, char *argv[])
{
int *aa = NULL,*bb = NULL;
fun(aa,bb);
printf("%03d:%03d\n",aa,bb);
return 0;
}
[解决办法]
#include <stdio.h>
void fun(int *a, int *b)
{
int x,y;
x = 5;
y = 6;
*a = x;
*b = y;
}
int main(int argc, char *argv[])
{
int aa ,bb;
fun(&aa,&bb);
printf("%03d:%03d\n",aa,bb);
return 0;
}