1 / 7

ENEE150 Discussion #3 Week 2/10

ENEE150 Discussion #3 Week 2/10. Header Files. “.h” files Declares prototypes for 1 program #include “ backgammon.h ” Change the prototype in header file, changes the prototypes in all the respective files. Header Files. By convention: Don’t put actual implementation code in “.h” files

zoe
Download Presentation

ENEE150 Discussion #3 Week 2/10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ENEE150 Discussion #3 Week 2/10

  2. Header Files • “.h” files • Declares prototypes for 1 program • #include “backgammon.h” • Change the prototype in header file, changes the prototypes in all the respective files

  3. Header Files • By convention: Don’t put actual implementation code in “.h” files • “.h” files need to be included in .c files • #include copy/pastes binary into your current file • Header Files include: • Function prototypes • Constants / Global Variables

  4. Compiling Multiple .c Files • Compile 3 files, generate 3 .o files, links them into 1 executable • Ex: gccboard.ccheck.cbackgammon.croll_die.c

  5. Extern Variables / Methods • Added to header files as a forward declaration of variable • Simple allocates space for the variable, but you still need to declare and create the variable • Can be declared any number of times, but only defined once Ex: extern int x;

  6. Testing Project 1 Manual vs Automation • Manual: Enter inputs into the file 2. Automation: Redirect file input and output

  7. Redirect Input/Output • 1. Use “<” to redirect standard input from a file Ex: sheet < sheet-test1.in • 2. Use “>” to redirect standard output to a file Ex: sheet < sheet-test1.in > output

More Related