C语言函数返回值

来源:百度知道 编辑:UC知道 时间:2024/05/23 16:58:12
谁能举个最最最简单的例子要求(用指针给我进行地址传递,小弟多个返回值格式不会)
一个Main函数和一个自定义函数,由main函数传2个以上实参去自定义函数 ,然后要返回2个以上的值(当然不能用return全图传会 用指针指针) 谢谢
从main传过去 后 在传回来是参数值做点修改吧 我更家能理解
不能用全局变量 不能用数组做参数 只给我用指针

#include<stdio.h>
void fun(char *s,int *a, int *b){

while(*s){

if((*s)>='A'&&(*s)<='Z'){
(*a)++;
}
if((*s)>='a'&&(*s)<='z')
(*b)++;
s++;
}
}
main()
{
char s[100];
int upper=0,lower=0;
int *upperp=&upper,*lowerp=&lower;
printf("\n Please a string:");
gets(s);
fun(s,upperp,lowerp);
printf("\n upper=%d lower=%d\n",upper,lower);
}