#include<stdio.h>
int main() { printf("before trans1\n"); int a1 = 10; printf("input value is %d, input address is %p\n", a1, &a1); trans1(a1); printf("after trans1\n"); printf("%d\n", a1);
}
// 传入的是一个值 void trans1(int x) { // 这里的打印值应该和main函数里的不一致,因为传入的是一个全新的数 printf("input x value is %d, input address is %p\n", x, &x); x += 100; }
// 传入的是int型指针 void xxxx.com trans2(int * x) { // 这里应该和外层的打印值是一样的 printf("input x value is %d, input address is %p\n", *x, x); // 取值之后,加100, *x += 100; }