[問題] 指向函式的指標語法..
以下是我練習--指向函式的指標語法
目的→x,y值 互換
想請教下面是哪出問題...x,y一直沒辦法互換
(一直沒辦法學好指標耶..)
<<程式開始>>
#include <stdio.h>
#include <stdlib.h>
float call(float x, float y , float(*ptr)(float,float)){
return (*ptr)(x,y);
}
float fun(float x, float y){
float temp;
temp = x;
x = y;
y = temp;
return x,y;
}
int main(){
float x,y;
printf("x = ");scanf("%f", &x);
printf("y = ");scanf("%f", &y);
printf("\n\n");
call(x,y,fun);
printf("對調後, x = %f\n", x);
printf(" , y = %f", y);
system("pause");
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.112.84.43
推
02/09 14:29, , 1F
02/09 14:29, 1F
→
02/09 14:30, , 2F
02/09 14:30, 2F
推
02/09 14:32, , 3F
02/09 14:32, 3F
→
02/09 14:32, , 4F
02/09 14:32, 4F
→
02/09 14:42, , 5F
02/09 14:42, 5F
→
02/09 14:53, , 6F
02/09 14:53, 6F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章