Re: Function prototypes



Steph Barklay wrote:

Hi, I'm currently taking a data structures course in C, and my teacher
said that function prototypes are not allowed in any of our code. He
also said that no professional programmers use function prototypes.

That implies, or very nearly implies,
that professional programmers don't write C programs
with more than one file of source code.

It also suggests that your teacher has never
written a C program with more than one file of source code,
and thus is a neophyte programmer.
How old is this kid?

I hope that you're mistaken about what he said.

This
kind of bugged me, because from other people's code that I've seen in
the past, almost all of them use function prototypes.
The following also
bugged me. Let's say you have a file called main.c with only the main
function, and includes hello.h, to use functions within hello.c. So
hello.h should contain prototypes for the functions in hello.c,
so when
main.c is compiled, there won't be any warnings. If there aren't any
prototypes in the header file, my compiler would assume the function
called with main() is extern and returns an int.
I tried to explain this to my teacher,
but the answer he gave me is that I should just put the
whole function within the header file
and not have any other *.c files.
I haven't seen anyone put whole functions
within header files before. Am I wrong about this

No.

or is my teacher wrong?

He absolutely does not understand what header files are for,
and is giving very strong indications
that he has no experience with multifile C programs.

Thank you.

Again, I very much hope that you have misunderstood what he meant.

--
pete
.



Relevant Pages

  • Re: Function prototypes
    ... Hi, I'm currently taking a data structures course in C, and my teacher ... also said that no professional programmers use function prototypes. ... my compiler would assume the function ... whole function within the header file and not have any other *.c files. ...
    (comp.lang.c)
  • Re: Function prototypes
    ... also said that no professional programmers use function prototypes. ... my compiler would assume the function ... whole function within the header file and not have any other *.c files. ... I wrong about this or is my teacher wrong? ...
    (comp.lang.c)
  • Re: Function prototypes
    ... also said that no professional programmers use function prototypes. ... Only fools (and those forced to use compilers so ancient ... just put the whole function within the header file and not have any ... Am I wrong about this or is my teacher wrong? ...
    (comp.lang.c)
  • Function prototypes
    ... Hi, I'm currently taking a data structures course in C, and my teacher ... also said that no professional programmers use function prototypes. ... my compiler would assume the function ... whole function within the header file and not have any other *.c files. ...
    (comp.lang.c)
  • Re: Function prototypes
    ... also said that no professional programmers use function prototypes. ... misunderstood what the teacher said (the blame for this ... good idea to discuss this matter with the teacher to clear ... then this is a very bad rule to teach to new programmers. ...
    (comp.lang.c)