lecture_16_revised

lecture_16_revised - 1 lecture_16_txt_1.txt 2010-10-14...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1 · lecture_16_txt_1.txt · 2010-10-14 12:28 · David Nicol Using functions in C requires - a function's prototype; or a function's declaration FUNCTION PROTOTYPE tells the compiler all it needs to know about calling the function, EXCEPT where the function is (!) example int Factorial(int n); this identifies * the return type (here int) * the symbolic name (so it can recognize calls to this function) * types of input arguments (here one int) why? The compiler needs to figure out how large the stack frame will be when the function is called - return value may be in the stack frame - arguments passed will be on the stack frame Prototypes are used - so that a function can be called from code in a file BEFORE the full function declaration is encountered in a top-to-bottom pass of the text - so that a function whose code is in a different file (or whose object code is in a library) can be called Other examples of function prototypes double cos(double); /* a trig function declared in math.h */ int getchar(void); /* reads a character from "STDIN" , often the keyboard */ A function need not return an argument, in that case the return type is of type "void" A function need not have any input arguments, in that case the prototype will specify
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 13

lecture_16_revised - 1 lecture_16_txt_1.txt 2010-10-14...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online