Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function prototype question

Status
Not open for further replies.

xailer

Programmer
Nov 6, 2003
13
SI
hi,Im learning c from a book written prior to today's ANSI standard and I noticed some things are quite different

1-Must a function which is called in a file before
it is defined,be declared with function prototype?

2-Can a Function prototype be declared in each function that calls this particular function,instead of being declared in the beginning of the file?

3-How about function that is defined before it is declared?
Is then function prototype not needed?

thank you
 
> Im learning c from a book written prior to today's ANSI standard
Get one that is for ANSI-C then. It may be of academic interest, but it's not for learning modern C from.

1. Yes
Declaring prototypes for everything irrespective of ordering of functions is the normal thing to do. You can get a quick overview of what the whole file is about simply from looking at the short list of prototypes at the start.

2. Yes
But doing so just creates a big maintenance problem in keeping them all consistent.

3. No.
But see comment on 1.

--
 
hi

>>Get one that is for ANSI-C then. It may be of academic interest, but it's not for learning modern C from.

I assumed most of the things didn't change.Am I wrong?

So the order functions are defined in a file does matter?

thank you for your help
 
> I assumed most of the things didn't change.Am I wrong?
Well a for loop still looks like a for loop, but there are quite a few smaller differences which you need to be aware of.
Function prototypes are perhaps the single biggest visible change from traditional C

> So the order functions are defined in a file does matter?
Only if you don't prototype everything in advance


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top