www.delorie.com/gnu/docs/glibc/libc_70.html   search  
Buy the book!

The GNU C Library

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. String and Array Utilities

Operations on strings (or arrays of characters) are an important part of many programs. The GNU C library provides an extensive set of string utility functions, including functions for copying, concatenating, comparing, and searching strings. Many of these functions can also operate on arbitrary regions of storage; for example, the memcpy function can be used to copy the contents of any kind of array.

It's fairly common for beginning C programmers to "reinvent the wheel" by duplicating this functionality in their own code, but it pays to become familiar with the library functions and to make use of them, since this offers benefits in maintenance, efficiency, and portability.

For instance, you could easily compare one string to another in two lines of C code, but if you use the built-in strcmp function, you're less likely to make a mistake. And, since these library functions are typically highly optimized, your program may run faster too.

5.1 Representation of Strings  Introduction to basic concepts.
5.2 String and Array Conventions  Whether to use a string function or an arbitrary array function.
5.3 String Length  Determining the length of a string.
5.4 Copying and Concatenation  Functions to copy the contents of strings and arrays.
5.5 String/Array Comparison  Functions for byte-wise and character-wise comparison.
5.6 Collation Functions  Functions for collating strings.
5.7 Search Functions  Searching for a specific element or substring.
5.8 Finding Tokens in a String  Splitting a string into tokens by looking for delimiters.
5.9 strfry  Function for flash-cooking a string.
5.10 Trivial Encryption  Obscuring data.
5.11 Encode Binary Data  Encoding and Decoding of Binary Data.
5.12 Argz and Envz Vectors  Null-separated string vectors.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003