int main(void)
{
int a[2];
double b[2];
printf("첫 번째 사람 나이, 키 : \n");
scanf("%d%lf", &a[0], &b[0]);
printf("두 번째 사람 나이, 키 : \n");
scanf("%d%lf", &a[1], &b[1]);
swap("int", &a, &b);
swap("double", &a, &b);
printf("첫 번째 사람 나이, 키 : %d %.1lf\n", a[0], b[0]);
printf("두 번째 사람 나이, 키 : %d %.1lf\n", a[1], b[1]);
return 0;
}
void swap(char *type, int* a[], double* b[])
{
double *dtmp;
int* tmp;
if (strcmp(type, "int") == 0)
{
tmp = a[0];
a[0] = a[1];
a[1] = tmp;
}
else if (strcmp(type, "double") == 0)
{
dtmp = b[0];
b[0] = b[1];
b[1] = dtmp;
}
}
첫 번째 : 22 187.5 두 번째 : 44 165.4 이렇게 초기화 했을때 함수실행시키고 나서 나이값은 바뀌는데 키값은 바뀌지 않습니다. 어떤게 문제인지 모르겠습니다ㅠ.