c语言形参改变实参

#include <stdio.h>
 
void funtion(int* b) {
    
    
    *b = *b - 10;
}
 
int main() {
    
    
    int x = 15;
    int y = 10;
    funtion(&x);
    funtion(&y);
    printf("x = %d\n", x);// 输出 x 
    printf("y = %d\n", y);// 输出 y 
    return 0;
}

输出:

x = 5
y = 0

猜你喜欢

转载自blog.csdn.net/qq_38312843/article/details/130087746
今日推荐