Previous Section
 < Free Open Study > 
Next Section


C.8 The Header File cstring

The header file cstring (not to be confused with the header file named string) supports manipulation of C strings (null-terminated char arrays).

strcat(toStr, fromStr)

  • Arguments:

C strings (null-terminated char arrays) toStr and fromStr, where toStr must be large enough to hold the result

  • Effect:

fromStr, including the null character '\0', is concatenated (joined) to the end of toStr.

  • Function return value:

The base address of toStr

  • Note:

Programmers usually ignore the function return value, using the syntax of a void function call rather than a value-returning function call.

strcmp(str1, str2)

  • Arguments:

C strings (null-terminated char arrays) str1 and str2

  • Function return value:

An int value < 0, if str1 < str2 lexicographically

The int value 0, if str1 = str2 lexicographically

An int value > 0, if str1 > str2 lexicographically

strcpy(toStr, fromStr)

  • Arguments:

toStr is a char array and fromStr is a C string (null-terminated char array), and toStr must be large enough to hold the result

  • Effect:

fromStr, including the null character '\0', is copied to toStr, overwriting what was there.

  • Function return value:

The base address of toStr

  • Note:

Programmers usually ignore the function return value, using the syntax of a void function call rather than a value-returning function call.

strlen(str)

  • Argument:

A C string (null-terminated char array) str

  • Function return value:

An int value 0 that is the length of str (excluding the '\0')



Previous Section
 < Free Open Study > 
Next Section
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)