C++ Characters, Strings, and the string Class PDF

Summary

This document is about C++ programming. It covers character testing and string manipulation using various C++ functions. Several programs are presented as examples to illustrate these concepts.

Full Transcript

Characters, Strings, and the string Class 1 10.1 Character Testing The C++ library provides several macros for testing characters. – Be sure to include ctype.h header file 2 Table 10-1 Character Descrip...

Characters, Strings, and the string Class 1 10.1 Character Testing The C++ library provides several macros for testing characters. – Be sure to include ctype.h header file 2 Table 10-1 Character Description Macro isalpha Returns true (a nonzero number) if the argument is a letter of the alphabet. Returns 0 if the argument is not a letter. isalnum Returns true (a nonzero number) if the argument is a letter of the alphabet or a digit. Otherwise it returns 0. isdigit Returns true (a nonzero number) if the argument is a digit 0–9. Otherwise it returns 0. islower Returns true (a nonzero number) if the argument is a lowercase letter. Otherwise, it returns 0. isprint Returns true (a nonzero number) if the argument is a printable character (including a space). Returns 0 otherwise. ispunct Returns true (a nonzero number) if the argument is a printable character other than a digit, letter, or space. Returns 0 otherwise. isupper Returns true (a nonzero number) if the argument is an uppercase letter. Otherwise, it returns 0. isspace Returns true (a nonzero number) if the argument is a whitespace character. Whitespace characters are any of the following: 3 Program 10-1 // This program demonstrates some of the character testing // functions. #include #include void main(void) { char input; cout

Use Quizgecko on...
Browser
Browser