From the course: Master C Language Pointers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Working with function pointers

Working with function pointers - C Tutorial

From the course: Master C Language Pointers

Start my 1-month free trial

Working with function pointers

- [Instructor] Like all variables, functions have data types. So just as integer and character functions exist, so do pointer functions. So here at line 8 is the F open function, and that returns a pointer of the file type. Effectively it returns the address of a file structure in memory. Which in this code is declared as pointer fp, and then assigned at line eight using the F open function. Any time a function returns an address, you must check the pointer to affirm the operation succeeded. This test is performed in this code at line 10. When the function fails, the symbolic constant null is stored in the pointer. If so, in this code, an error message is output and the program exits. The address returned from a pointer function matches the function's data type, which is true for any type of function. So here you see an integer pointer function, iptr, declared at line 4. It returns an address, the address of an…

Contents