08-Functions.pptx - ICS 212 Program Structure William McDaniel Albritton M.S Memory Allocation Header files C Standard Library Math functions

08-Functions.pptx - ICS 212 Program Structure William...

This preview shows page 1 - 15 out of 58 pages.

ICS 212 Program Structure William McDaniel Albritton M.S.
Image of page 1
Memory Allocation Header files C Standard Library Math functions Trigonometric functions Random number generation
Image of page 2
Image of page 3
Header Files
Image of page 4
#include #include is a preprocessor directive Using #include causes a copy of the specified file to be included in place of the directive We have used it with <stdio.h> and other header files
Image of page 5
#include #include is used for C Standard Library header files (note the angled brackets: < >) And for programmer-defined header files (note the double-quotes: " ") #include <filename.h> #include “filename.h”
Image of page 6
#include "filename.h" For programmer-defined header files, the preprocessor looks for the file in the same directory as the file being compiled
Image of page 7
Example Header File For an example header file, see getdouble.h The function definition for function getdouble() is stored in file getdouble.c #define MAX 100 double getdouble();
Image of page 8
Example Program Any program that uses function getdouble() must include the header file For example, file inputdouble.c includes the header file getdouble.h, so it can use the function getdouble() #include “getdouble.h”
Image of page 9
Image of page 10
C Standard Library
Image of page 11
C Standard Library Prepackaged functions already written Each library has a header file, which is the interface (list of function prototypes) to the library functions The header file also contains macros and variables Library files are binary files in machine code Header files are text files in the C language
Image of page 12
Header Files from C Standard Library Header file : Description <assert.h> : Diagnostics used to detect logical errors <ctype.h> : Character functions to see if uppercase, etc. <errno.h> : Test error codes reported by library functions <float.h> : Macro constants for floating-point limits <limits.h> : Macro constants for
Image of page 13
Header Files from C Standard Library Header file : Description <locale.h> : Locale-specific I/O for numbers, currency, etc. <math.h> : Mathematical functions <setjmp.h> : Non-local jumps to different functions <signal.h> : How to handle signals, such as division by zero <stdarg.h> : Functions can have infinite arguments
Image of page 14
Image of page 15

You've reached the end of your free preview.

Want to read all 58 pages?

  • Spring '18
  • Trigonometry, Randomness, Inverse function, Logarithm, C standard library

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes