C语言中函数返回值的类型是由 谁决定?

如题所述

int hello(){
char a='a';
return a; //返回的是 97
}
char hello(){
int a=97;
return a; //返回的是 a
}
但是这样你又看不出来。如果学过c++的话用cout<<hello()<<endl; 分别输出这两个函数就可以了。
给你写个完整代码。可以直接在dev c++中运行
#include<iostream>
using namespace std;
int hello1(){
char a='a';
return a; //返回的是 97
}
char hello2(){
int a=97;
return a; //返回的是 a
}
int main(){
cout<<hello1()<<" "<<hello2()<<endl;
getchar();//为了暂停看一下结果
return 0;
}
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答