A
Anthony Irwin
Hi all,
I have been going through the k&r2 book and all the examples are done
with main() instead of int main(void) and k&r2 in the start of chapter
1 does not return 0 so I haven't yet either.
I did two compiles shown below.
$ gcc -std=c89 -Wall exercise_1-9.c -o exercise_1-9
exercise_1-9.c:5: warning: return type defaults to `int'
exercise_1-9.c: In function `main':
exercise_1-9.c:27: warning: control reaches end of non-void function
$ gcc -std=c99 -Wall exercise_1-9.c -o exercise_1-9
exercise_1-9.c:5: warning: return type defaults to `int'
Why doesn't k&r2 have the int return type on main and why doesn't c99
care that I reached the end of a non-void function without returning a
value.
Kind Regards,
Anthony Irwin
I have been going through the k&r2 book and all the examples are done
with main() instead of int main(void) and k&r2 in the start of chapter
1 does not return 0 so I haven't yet either.
I did two compiles shown below.
$ gcc -std=c89 -Wall exercise_1-9.c -o exercise_1-9
exercise_1-9.c:5: warning: return type defaults to `int'
exercise_1-9.c: In function `main':
exercise_1-9.c:27: warning: control reaches end of non-void function
$ gcc -std=c99 -Wall exercise_1-9.c -o exercise_1-9
exercise_1-9.c:5: warning: return type defaults to `int'
Why doesn't k&r2 have the int return type on main and why doesn't c99
care that I reached the end of a non-void function without returning a
value.
Kind Regards,
Anthony Irwin