不要编译,你猜猜这个程序会有几个类型匹配的警告?
下面这个程序是经典著作《The c programming language》(第一版)上的
其实错误没有,但是编译肯定是有警告的!你看看有几个(不要用工具先想想)
/**********************
print Fahrenheit-Celsius table
for 0, 20, ..., 300
filename : c1_1.c
************************/
#include <stdio.h>
void main()
{
int lower, upper, step;
double fahr,celsius;
lower = 0; /* lower limit of temperature table */
upper = 300; /* upper limit */
step = 20; /* step size */
fahr = lower;
while(fahr <= upper)
{
celsius = (5.0/9.0) * (fahr - 32.0);
printf("%4d %6.1f \n",fahr, celsius);
fahr += step;
}
}
当然后来第二版的时侯,作者已经对这个程序进行了很大的修改!