我有一个简单的c程序
#include <stdio.h>
int add(int, int);
int add (int a, int b) {
return a+b;
}
int main(void) {
int a, b, c;
printf("Enter the 1st number ");
scanf("%d",&a);
printf("Enter the 2nd number ");
scanf("%d",&b);
c = add(a, b);
printf("The value is %d ", c);
return (0);
}
我正在编译程序cc main.c
当我运行程序时./a.out
我在控制台中没有得到任何输出。
出于性能原因,对输出进行缓冲。代替
printf("The value is %d ", c);
with
printf("The value is %d\n", c);
or use fflush(stdout);
.
See 为什么 printf 在调用后不会刷新,除非格式字符串中有换行符? https://stackoverflow.com/questions/1716296/why-does-printf-not-flush-after-the-call-unless-a-newline-is-in-the-format-strin
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)