O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

String Handling: string.h

The C language has no built-in string data type and as such no built-in operators for string handling. The string library provides many functions for manipulating character arrays as memory blocks, known as null-terminated strings.

This last point is important—all strings that are to be processed with the string library must be null terminated. In essence, this just means that the last character in the array must be a \0 character. Assuming you have a character array with the characters Hello in it, you could do this as follows:

szMyString[5] = '\0';

The only slight issues are remembering that arrays are zero indexed, meaning that the first element is 0, and the last element is size - 1, and that each array will have ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required