Đang chuẩn bị liên kết để tải về tài liệu:
A Complete Guide to Programming in C++ part 16

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

A Complete Guide to Programming in C++ part 16. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | STANDARD MACROS FOR CHARACTER MANIPULATION 129 The following section introduces macros that classify or convert single characters. The macros are defined in the header files ctype.h and cctype. Case Conversion You can use the macro toupper to convert lowercase letters to uppercase. If cl and c2 are variables of type char or int where cl contains the code for a lowercase letter you can use the following statement Example c2 toupper ci to assign the corresponding uppercase letter to the variable c2. However if cl is not a lowercase letter toupper cl returns the character as is. The sample program on the opposite page reads standard input converts any letters from lower- to uppercase and displays the letters. As toupper only converts the letters of the English alphabet by default any national characters such as accentuated characters in other languages must be dealt with individually. A program of this type is known as a filter and can be applied to files. Refer to the next section for details. The macro tolower is available for converting uppercase letters to lowercase. Testing Characters A number of macros all of which begin with is. are available for classifying characters. For example the macro islower c checks whether c contains a lowercase letter returning the value true in this case and false in all other cases. Example char c cin c Reads and classifies if isdigit c a character. cout The character is no digit n The following usage of islower shows a possible definition of the toupper macro Example define toupper c islower c c - a A c This example makes use of the fact that the codes of lower- and uppercase letters differ by a constant as is the case for all commonly used character sets such as ASCII and EBCDIC. The opposite page contains an overview of macros commonly used to classify char acters. 130 CHAPTER 7 SYMBOLIC CONSTANTS AND MACROS REDIRECTING STANDARD INPUT AND OUTPUT Sample program lines.cpp A filter that numbers lines. include iostream include .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.