Page 86 - Modular_V1.1_Flipbook
P. 86

In the preceding line, we have included the iostream.h header file. Now, you can use all the
                  functions defined in the iostream.h header file in your program. You can also use “” (double

                  quote) in place of angular brackets. The use of angle brackets < > instructs the compiler to
                  search the compilers include directory for the specified header file. On the other hand, the use
                  of the double quote “ “ instruct the compiler to search in the current directory for the specified
                  header file.
                  Let us use some of the library functions to understand the concepts better.
                  Functions of ctype.h Header File


                  The ctype.h header file contains the definitions of character handling functions. You need to
                  include this header file in your program to use the character functions. Some of the commonly
                  used functions of the ctype.h header file are:

                    Function Name                           Use                          Example           Output
                   isalpha(char c)     It returns  true  if the  character  c is an  isalpha(‘B’)       True

                                       uppercase or a lowercase letter. Otherwise
                                       returns false.
                   islower(char c)     It returns true if the character c is a lowercase  islower(‘B’)  False
                                       letter. Otherwise returns false.

                   isupper(char c)     It returns  true  if the  character  c is an  isupper(‘B’)       True
                                       uppercase letter. Otherwise returns false.

                   isdigit(char c)     It returns true if the character c is a digit  isdigit(‘9’)      True
                                       from 0 through 9. Otherwise returns false.


                   isalnum(char c)     It returns true if character c is a digit from  isdigit(‘$’)     False
                                       0 through 9 or a letter either uppercase or
                                       lowercase. Otherwise returns false.
                   tolower(char c)     It converts the character c to lowercase if  isupper(‘B’)        b
                                       it  is  in  uppercase.  Nothing  will  change  if
                                       the character is a lowercase letter or a non-
                                       alphabetic character.

                   toupper(char c)     It converts the character c to uppercase if it  isupper(‘b’)     B
                                       is in lowercase. Nothing will change if the
                                       character is an uppercase letter or a non-
                                       alphabetic character.

                  Program 1: To use character handling functions.
                  #include<iostream.h>

                  #include<ctype.h>
                  #include<conio.h>

                  void main()

                  84      Touchpad MODULAR (Version 1.1)-X
   81   82   83   84   85   86   87   88   89   90   91