lenaben

通过另一个函数,改变主函数中的局部变量

1.通过另一个函数,改变主函数中的局部变量

#include<stdio.h>

#include<stdlib.h>

void main(int *x){

 *x=300

}

void main(){

int x=200;

f_test(&x);

printf("x is %d\n",x);

system("pause");

}

 

2.数组

#include<stdio.h>

#include<stdlib.h>

void test2(){

int l_arr[]={1,2,3,4,5};

int l_v1=1;

int l_v2=2;

int l_temp;

l_temp=l_arr[1];

l_temp=l_arr[l_v1];

l_temp=l_arr[l_v1+l_v2];

l_temp=l_arr[l_v1*2+l_v2];

l_temp=l_arr[l_arr[1]+l_arr[2]];

l_temp=l_arr[7];

}

void main(){

test2();

system("pause");

}

 

posted on 2017-09-05 22:10  lenaben  阅读(364)  评论(0)    收藏  举报

导航