我想知道为什么下面的程序可以在gcc中编译,但是当我使用./abs(脚本的名称)时不会给出任何输出。
#include <stdio.h>
#include <stdlib.h>
double AbsoluteValue(double x)
{
if (x > 0)
{
return x;
}
else if (x < 0)
{
return -x;
}
}
int main (void)
{
AbsoluteValue(2.00);
}
最佳答案
没有输出,因为代码没有打印任何内容。将您的 main
更改为:
int main (void)
{
double d;
d = AbsoluteValue(2.00);
printf("%f\n", d);
return 0;
}
关于c - 当我在简单的 C 程序中返回值时,我没有收到任何消息。我该如何解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25785753/