UMBC CMSC 201
Fall '06

CSEE | 201 | 201 F'06 | lectures | news | help

Strings

  • Strings are sequences of characters that are terminated with a the special character, the NULL character, '\0'.

  • Strings are represented as arrays of characters, where the last character of the string is the NULL character, '\0'.

  • This combination declaration and initialization: char str[5] = "cat"; has the following representation.

    str

    FE09

    'c'

    'a'

    't'

    '\0'

    .

    Have you heard this one??


    These two strings walk into a bar and sit down.
    The bartender says, "So what'll it be?"

    The first string says, "I think I'll have a beer quag fulk boorg2jdk^C"

    The second string says, "Please excuse my friend. He isn't null-terminated."


  • Many functions have already been written for manipulating strings and they are found in the ANSI C string library.

  • To use functions in this library you'll need to #include <string.h>


    CSEE | 201 | 201 F'06 | lectures | news | help

    Last Modified - Tuesday, 22-Aug-2006 07:14:18 EDT