This code takes advantage of a historical quirk of C where types are
assumed to be int unless otherwise specified:
foo(x) {...} is equivalent to int foo(int x)
{...}. Additionally the printf works because gcc
includes stdio.h by default, and main is
special-cased to assume a final return 0.
I’ve occasionally used this style when writing example code to
remove visual noise, but it’s probably not a good idea there either.
Implicitly Typed C
Link post
I don’t know any good reason to do this, but if you would rather be writing Python or JavaScript here’s something you can do with a C compiler:
This code takes advantage of a historical quirk of C where types are assumed to be
int
unless otherwise specified:foo(x) {...}
is equivalent toint foo(int x) {...}
. Additionally theprintf
works because gcc includesstdio.h
by default, andmain
is special-cased to assume a finalreturn 0
.I’ve occasionally used this style when writing example code to remove visual noise, but it’s probably not a good idea there either.
Comment via: facebook, mastodon