还可以这样// ConsoleApplication2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
/*****以指针为参数,调用函数,从数组中找出最大值 与最小值 *****/
int a[10] = { 32, 85, 32, 59, 96, 75, 58, 98, 39, 108 };
int *p, *max, *min;
p = max = min = a;
void max_min_value(int **t, int **b, int **c);
max_min_value(&p, &max, &min);
printf("max=%d,min=%d\n", *max, *min);
getchar();
return 0;
}
void max_min_value(int **t, int **b, int **c) //查找最大值与最小值
{
int i;
for (i = 0; i<10; i++, (*t)++)
{
if (**t>**b)
*b = *t;
if (**t < **c)
*c = *t;
}
}
这个是函数调用时参数传递的问题,C语言是值传递的方式传参,所以call max_min_value的时候只是将原来的p max min 复制一份成为 t b c 你对 t b c的任何操作都不会改变原来的额 p max min |