目的: 使用指针传递地址.
solveNumbers.c / C
#include <stdio.h>
void solveNumbers(int data,
int * hundreds, int * tens, int * ones)
{
*hundreds = (data % 1000) / 100;
*tens = (data % 100) / 10;
*ones = (data % 10) / 1;
}
int main()
{
int data;
int hs, ts, os;
printf("Input a number: ");
scanf("%d", &data);
solveNumber(data, &hs, &ts, &os);
printf("\nhundreds = %d, tens = %d, ones = %d\n",
hs, ts, os);
getch();
return 0;
}
因为 &hs = hundreds;
所以 hs = *hundreds;
xucun915_925777961 2011-8-29 14:53
walnutcy_696810119 2008-8-21 17:11
用户461316 2008-8-20 16:26