Пример #1
0
void test() {
//  数组作为函数传递是地址传递
    int nums[] = {2, 1};
    printf("nums  = %p\n", nums);
    
    changeArray(nums);
    
    printf("%d\n", nums[1]);
    
}
Пример #2
0
int main(void){
	//let's declare an array to play with
	int test[4] = {1,2,3,4};
	int i;
	//display the array
	for(i = 0; i < 4; i++){
		printf("test index %d is %d\n", i, test[i]);
	}
	//pass it to a function that tries to change the values in the array
	changeArray(test, 4);
	printf("After calling changeArray:\n");
	//print out the array again
	for(i = 0; i < 4; i++){
                printf("modified? test index %d is %d\n", i, test[i]);
        }
		
}