I came across this code in Stephen G Kochan’s book, Programming in c. Is this possible?
float absolute_value(x)
float x;
{
-----
-----
}
So, as you can see, the argument x is declared after it’s used it the method arguments. This throws an obvious compilation error in G++.
So, which C compiler supports this?
That’s the old style K&R format. It’s not actually declaring the argument
x, rather defining its type. By default, things wereintunless otherwise specified.Back when C was a much simpler language, not that far removed from my beloved BCPL, this was how you gave function arguments their types. None of these prototype stuff that you young whippersnappers take for granted.
Oh yeah, and get off my lawn 🙂