Exercise 24. Input, Output, Files

You’ve been using printf to print things, and that’s great and all, but you need more. In this exercise, you’ll be using the functions fscanf and fgets to build information about a person in a structure. After this simple introduction about reading input, you’ll get a full list of the functions that C has for I/O. Some of these you’ve already seen and used, so this will be another memorization exercise.

ex24.c

  1   #include <stdio.h>   2   #include "dbg.h"   3   4   #define MAX_DATA 100   5   6   typedef enum EyeColor {   7       BLUE_EYES, GREEN_EYES, BROWN_EYES,   8       BLACK_EYES, OTHER_EYES   9   } EyeColor;  10  11   const char *EYE_COLOR_NAMES[] = {  12       "Blue",

Get Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.