It's funny that When I started out the examples in the tutorials seem to have always started with just 'main()' After I studied 'main' for a while I would automatically type in 'void main(void)' (if appropriate) and I could get away with it then. I had heard that the requirement for 'main' had changed so that it always returned something, but wasn't sure until I read your responses.
Well, the bad thing about most C tutorials/manuals back then was that they kept referring to the at this point already obsolete "K&R C" while ANSI C standardization started in 1983 and was first published as "C89", well in 1989...
I started with C sometime in the late 1970's on Apple DOS and CP/M, and all those compilers were not (yet) ANSI C. But as soon as the ANSI C proposal came out in the early 1980's, I immediately switched to using it, as it simply made more sense and resulted in clearer code. That was also one of the reasons why I switched back in the early DOS days from DeSmet C to Turbo C, as the later not only had a nicer IDE but also already understood what would become ANSI C notation.
I guess I didn't make myself clear when I described the problem. I'm getting the error messages from the function definition and not the function. Maybe I should call it the 'parameter declaration.'
Well, the there is that you only posted part of your source, not the whole thing. It seems you are making two different declarations, to get around the odd habit of (old) C to declare every thing that isn't already explicitly declared as int. The main point is that those declarations need to be of the same "style", not using K&R in one place and ANSI in the other...
My reference book, which is "Using Turbo C Second Edition" covering Turbo C 2.0, is really confusing me. It explains the difference between the 'Classic' parameter declaration statement and the ANSI version but it's a little vague about which code block is which type.
Not sure what so confusing about this (I don't have any manuals before Turbo C(++) 3.0 anymore).
You should simply define each parameter "in place" in ANSI C, there aren't actually different code blocks anymore.
Or you need to post some more comprehensive examples of what you mean to make things more clear...
I'm going to assume that, when it says
f(type varname1, type varname 2, type varnameN)
That appears to be a fairly accurate example of the ANSI standard, but later on it says:
For example, this modern declaration
float f(int a, int b, char ch)
{
.
.
.
}
This is where it gets confusing. Is the second example ANSI standard? I assume that something is supposed to be on the three lines that just have a '.' in them. Does that mean, if he expanded it, the ANSI standard says it should look like this?
yes, that would be ANSI C notation, and well, those lines with the "." in them, that simply would be the code that actually presents your function "f"
float f(int a, int b, char ch)
{
int a;
int b;
char ch;
}
Sorry, but that code doesn't make any sense. First of all, there is no "code" and there is no need to re-declare the parameters as you did this already in the declaration of the function f() already...
Ralf