C Lecture 6

[Previous Lecture] [Lecture Index] [Next Lecture]

File Input/Output


Parameter passing:


{...} block variables:

static {...} block variables:

global variables:

static global variables:


strtok.c


char *
strtok(char *str, char *delims)
{
    static char *pos = (char *) 0;
    char *start = (char *) 0;

    if (str)    /* Start a new string? */
        pos = str;

    if (pos) {
        /* Skip delimiters */
        while (*pos && strchr(delims, *pos))
            pos++;
        if (*pos) {
            start = pos;
            /* Skip non-delimiters */
            while (*pos
		   && !strchr(delims, *pos))
                pos++;
            if (*pos)
                *pos++ = '\0';
        }
    }

    return start;
}

Storage classes:

Qualifiers:


Symbolic constants

Two methods of defining constants:

#define

Enumerations

enum enum-name { ident-name , ... };
enum fruit { apple, orange, pear };

[Previous Lecture] [Lecture Index] [Next Lecture]