userdefined函数中的返回类型bool没有返回任何内容?
问题描述:
我的程序没有返回任何值...当我尝试在不使用用户定义函数的情况下解决此问题并使用printf()输出消息该三角形是否有效时,其工作
我的尝试:
my program is not returning any value...when i try to solve this problem without using user defined function and use printf() to output the message "that triangle is valid or not" ,its working
What I have tried:
#include<stdio.h>
#include <stdbool.h>
bool triangle( int a,int b,int c);
int main(void){
printf("enter three side of triangel to check if triangle exist\n");
int x=get_int();
int y=get_int();
int z=get_int();
triangle(x,y,z);
}
bool triangle( int a,int b,int c)
{
if((a>0&&b>0&&c>0)&&(a+b>c&&b+c>a&&a+c>a)){return true;}
else{ return false;}}
答
函数DOES返回一个值。你只是没有抓住它并用它做任何事情。
你打电话给三角形(x,y,z);
不捕获返回值。它应该是
The function DOES return a value. You're just not capturing it and doing anything with it.
Your call totriangle(x,y,z);
doesn't capture the return value. It should be
bool c;
c = triangle(x,y,z);
...