void main()
{
int a = 10;
double b = 3.5;
void *vp;
vp = &a;
printf(" a : %d", *(int *)vp);
vp = &b;
printf(" b : %f", *(double *)vp);
}
void reserve(double *pa, int size);
int main(void)
{
double ary[] = { 1.5, 20.1, 16.4, 2.3, 3.5 };
int i;
reserve(ary, sizeof(ary) / sizeof(*ary));
for (i = 0; i < 5; i++) {
printf("%5.1lf", ary[i]);
}
printf("\n");
return 0;
}
void reserve(double *pa, int size)
{
double tmp = 0;
int j=0;
for (int i = 0; i < 5/2; i++)
{
tmp = pa[i];
pa[i] = pa[size - 1 - i];
pa[size - 1 - i] = tmp;
}
}
반응형