Я предполагаю, что вы компилируете с отключенными предупреждениями. Вот что я получаю:
gcc -std=c11 -fPIC -g -Wall -Wextra -Wwrite-strings -Wno-parentheses -Wpedantic -Warray-bounds -O2 -c -o 40157429.o 40157429.c
40157429.c: In function ‘main’:
40157429.c:13:5: warning: ISO C forbids nested functions [-Wpedantic]
int tempconvert(lower, upper, step){
^~~
40157429.c: In function ‘tempconvert’:
40157429.c:13:9: warning: type of ‘lower’ defaults to ‘int’ [-Wimplicit-int]
int tempconvert(lower, upper, step){
^~~~~~~~~~~
40157429.c:13:9: warning: type of ‘upper’ defaults to ‘int’ [-Wimplicit-int]
40157429.c:13:9: warning: type of ‘step’ defaults to ‘int’ [-Wimplicit-int]
40157429.c:20:5: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
40157429.c: In function ‘main’:
40157429.c:7:23: warning: variable ‘step’ set but not used [-Wunused-but-set-variable]
int lower, upper, step;
^~~~
40157429.c:7:16: warning: variable ‘upper’ set but not used [-Wunused-but-set-variable]
int lower, upper, step;
^~~~~
40157429.c:7:9: warning: variable ‘lower’ set but not used [-Wunused-but-set-variable]
int lower, upper, step;
^~~~~
At top level:
40157429.c:13:9: warning: ‘tempconvert’ defined but not used [-Wunused-function]
int tempconvert(lower, upper, step){
^~~~~~~~~~~
Вы можете исправить эти ошибки, встраивание:
#include <stdio.h>
int main(void) {
float fahr, celsius;
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
fahr = lower;
while (fahr <= upper) {
celsius = (5.0/9.0) * (fahr-32.0);
printf("%3.0f %6.1f\n", fahr, celsius);
fahr = fahr + step;
}
return 0;
}
или путем перемещения контура в функции:
#include <stdio.h>
void tempconvert(int, int, int);
int main(void) {
int lower, upper, step;
lower = 0;
upper = 300;
step = 20;
tempconvert(lower, upper, step);
return 0;
}
void tempconvert(int lower, int upper, int step){
float fahr = lower;
while (fahr <= upper) {
float celsius = (5.0/9.0) * (fahr-32.0);
printf("%3.0f %6.1f\n", fahr, celsius);
fahr = fahr + step;
}
}
оба из которых делают то, что вы, кажется, хотеть.
У вас нет встроенных функций в C. – EOF
Но даже если бы вы могли - вы не называете это ... –
@EOF Я думаю, что gcc имеет нестандартное расширение, которое позволяет это. –