{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lec5 - CS240 Programming in C Lecture 5 Functions Scope 1...

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

View Full Document Right Arrow Icon
CS240: Programming in C Lecture 5: Functions. Scope. 1 Sunday, January 23, 2011
Background image of page 1

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

View Full Document Right Arrow Icon
Functions: Explicit declaration Declaration, definition, use, order matters. Declaration : defines the interface of a function; i.e., number and types of parameters, type of return value A C PROTOTYPE gives an explicit declaration void solve(int [], int, int); Prototypes improve safety and robustness Improved interaction with the type-checker 2 Sunday, January 23, 2011
Background image of page 2
Functions: Implicit declaration First use of a function without a preceding prototype declaration implicitly declares the function If prototype follows the first use, error will say prototype is wrong Put prototypes of function at the beginning of the source file! 3 Sunday, January 23, 2011
Background image of page 3

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

View Full Document Right Arrow Icon
Functions: Definition DEFINITION gives the implementation of a function int my_strlen(char s[]) { int i = 0; while(s[i] != ‘\0’) ++i; return i; } Are functions a form of abstraction ? The notion of an abstraction is a central concept in programming languages 4 Sunday, January 23, 2011
Background image of page 4
int my_strlen(char* s) { int i = 0; while(*(s+i) != ‘\0’) ++i; return i; } 5 Sunday, January 23, 2011
Background image of page 5

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

View Full Document Right Arrow Icon
int my_strlen(char* s) { int i = 0; while(*(s+i) != ‘\0’) ++i; return i; } What does this signify?
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}