CS 102
[Schedule] [Examples] [Programs] [Notes & Reference] [Syllabus] [Lab & TA] [Tests] [Grades]

Strings

Motivation, Examples, Pointers, String Functions, Online Doc

Motivation

We often need to manipulate stored text in C. This can be done using arrays of characters, which are called strings.

Examples reading in strings

arrayStrings.c: using arrays to store strings, reading with %s, overwriting the '\0' at the end of a string. (See also a version tailored for the EECS machines)

encode.c: encoding some input text by a set transposition amount

A Brief Introduction to Pointers

See in-class notes

arrayptr1.c: An example using a pointer with an array

Examples of String Functions

A description of some of the string functions.

stringFcns.c: A program using various string functions: strcat, strcmp, strcpy, strlen, strstr, strchr, strncpy

parse.c: A better way to repeatedly pull out words using strtok

On-line documentation

See string.h in the C standard library functions.


[CS Dept] [UIC] [Prof. Reed]