我刚开始编码,所以我将CS50的库用作我的训练轮。我尝试制作一个自定义函数,但是每次尝试编译它时,都会收到一个错误,其中涉及将字符串声明为我的自定义函数的返回类型,因为我已经包含了cs50的库,因此编译器应该能够识别出什么是字符串,为什么我的代码无法编译?
这是我的参考代码,(我正在谈论的自定义函数是涉及三角形的那个)
#include<cs50.h>
#include<stdio.h>
string triangle (int a, int b, int c); //declaration
int main(void)
{
int x = get_int("a : ");
int y = get_int("b : ");
int z = get_int("c : ");
string answer = string triangle(x , y, z)
printf("%s /n", answer);
}
string triangle (int a, int b, int c)
{
if (a < 0 || b < 0 || c < 0)
{
printf("false");
}
if (a + b <= c || a + c <= b || b + c <= a)
{
printf ("false");
}
else {
printf("true");
}
}