Outline for May 20, 2002

Handouts: Binary Tree
Reading: Johnsonbaugh and Kalin, pp. 679-702 (appendix of useful functions)


  1. Greetings and felicitations!
  2. Directory functions
    1. DIR *, struct dirent (#include <dirent.h>)
    2. opendir, readdir, closedir
  3. Example program: binary tree
  4. Libraries
    1. compiling with libraries
    2. common libraries: stdio, ctype
  5. Standard I/O Library (#include <stdio.h>)
    1. open file: fopen
    2. unstructured read/write: getchar, fgetc (getc), putchar, fputc (putc)
    3. formatted read/write: fgets (gets), fscanf, fputs (puts), fprintf
    4. structured read/write: fread, fwrite
    5. random access: fseek, ftell, rewind
    6. close file: fclose
    7. miscellaneous: feof, ferror, clearerr
  6. Character types and conversions (#include <ctype.h>)
    1. alphabetics, numerics, alphanumerics: isalnum, ialdigit, isxdigit, isalpha
    2. ypper, lower, and conversions: isupper, islower, toupper, tolower
    3. types of chars: iscntrl, isgraph (not blank, printable), isprint (printable), ispunct, isspace
  7. String conversion (#include <stdlib.h>)
    1. string to number: atoi, atof, atol
  8. String functions (#include <string.h>)
    1. compare: strcmp, strncmp, strcasecmp, strncasecmp; memcmp
    2. copy: strcpy, strncpy; memcpy (no overlap), memmove (overlap okay)
    3. find character: strchr (index), strrchr (rindex), strpbrk; memchr
    4. length: strlen
  9. Memory management (#include <stdlib.h>
    1. Allocation: malloc, calloc
    2. Release: free, cfree (deprecated)
    3. Reallocation: realloc()
  10. Miscellaneous
    1. terminate program (exit); include <stdlib.h>
    2. sort array of data (qsort); include <stdlib.h>
    3. time of day (time, ctime); include <time.h>
    4. execute cvommand (system); include <stdlib.h>


ECS 30-A, Introduction to Programming
Spring Quarter 2002
Email: cs30a@cs.ucdavis.edu