Character and String functions

These functions are used for manipulating characters.

1. isalnum()

This functions carries out the test "Is the character alphanumeric?". An alphanumeric character is a letter of either lower or upper-case, or a digit. It has a prototype in the header file ctype.h. The argument to this function is a character represented as an integer.

The function isalnum() returns a non-zero value if the character is alphanumeric and zero if it is not so.

2. isdigit()

This function carries out the test "Is the character a digit?". It has a prototype in the header file ctype.h. The argument to this function is also characte represented as an integer.

The function isdigit() returns a non-zero value if the character is a digit and a zero if it is not so.

3. isalpha()

This function carries out the test "Is the character alphabetic?". It has a prototype in the header file ctype.h.

It returns a non-zero value if the character is a letter of either (ie upper or lower) case and zero if it is not so.

4. islower()

this function carries out the test "Is the character a lower-case letter?". It has a prototype in the header file ctype.h.

It returns a non-zero if the character is a lower-case letter and a zero if it is not so.

5. isupper()

This function carries out the test "Is the character an upper-case letter?".It has a prototype in the header file ctype.h.

6. tolower()

This function is the case conversion function. It converts an upper case character to its lower case value. If the character is an upper case letter (A to Z), it is converted to its lower case ( a to z). This function has a prototype in the header file ctype.h.

7. toupper()

This function is the case conversion function. It converts an lower case character to its upper case value. If the character is a lower case letter (a to z), it is converted to its upper case value ( A to Z). This function has a prototype in the header file ctype.h.

String Functions

These standard library functions are used for the manipulation of strings.

1. strcpy()

The function strcpy() is used for copying one string to another. This function has a prototype in the header file string.h.

The syntax of this function is :

strcpy(destination, source);

Using strcpy(), the source string is copied to the destination string. This copying action terminates after the null character '\0' has been moved from source string to the destination string.

2. strcat()

The function strcat() appends a source string to the end of the destination string. The length of the resulting string is equal to total of both the strings. this function has a prototype in the header file string.h.

3. strlen()

The function strlen() calculates the length of a string. the argument to this function is a string. It returns the number of characters in the string except the null character '\0'. It has a prototype in the header file string.h.

4. strcmp()

The function strcmp() compares two strings with case senstivity. the comparision starts with the first character of every string and continues with subsequent characters until the end of the strings is reached or the corresponding characters differ. It has a prototype in the header file string.h.

5. strcmpi()

This function strcmpi() compares two strings treating both upper and lower case letters to be equal. It has a prototype in the header file string.h.

HOME LEARN C++ PREVIOUS NEXT