[Skip Navigation] [CSUSB] / [CNS] / [Comp Sci Dept] / [R J Botting] / [Samples] / c++.libraries
[Index] [Contents] [Source Text] [About] [Notation] [Copyright] [Comment/Contact] [Search ]
Tue Sep 18 15:25:10 PDT 2007


    Some Standard C++ function libraries

      The STL is documented elsewhere [ stl.html ] on this site.

      Here are some of the C libraries that have been inheritted by C++.


        Originally <ctype.h> and useful for character handling. In C++
         		#include <cctype>
        and in C
         		#include <ctype.h>

        One of the oldest and most useful C++ libraries is the Character Type library inheritted from ANSI C. You use these function to classify characters by their type and they work on even weird character sets like EBCDIC.

        On the other hand they don`t work on strings or arrays of characters.

        Most of the fucntions test for particular types of characters, but two function change a characters case...

        In the following list c stands for a char.

      1. For c:char.

      2. isalnum(c)::bool=c is an alphanumeric character.
      3. isalpha(c)::bool=c is a letter.
      4. iscntrl(c)::bool=c is a special control character, ASCII(0)..ASCII(31).
      5. isdigit(c)::bool=c is a decimal digit, '0'..'9'.
      6. isgraph(c)::bool=c is a graphic character, a printing character other than space.
      7. islower(c)::bool=c is a lower case letter, 'a'..'z'.
      8. isprint(c)::bool=c is not a control character but prints something including a space.
      9. ispunct(c)::bool=c is a punctuation character = isprint(c) && !isspace(c) && !isalnum(c).
      10. isspace(c)::bool=c is a white space character including space, tab, newline, carriage return etc..
      11. isupper(c)::bool=c is an UPPER CASE LETTER.
      12. isxdigit(c)::bool=c is a hexadecimal digit, '0'..'9' | 'A'..'F' | 'a'..'f'.

        The following functions we defined backwards until gisli_tru@hotmail.com sent me Email pointing out my mistake. Thank you!

      13. toupper(c)::char=converts lower case letters into upper case letters and copies all others.
      14. tolower(c)::char=converts upper case letters into lower case letters and copies all others.

        For more see [ c++.cctype.html ] (including sample code etc).

      . . . . . . . . . ( end of section cctype) <<Contents | End>>


      AKA stddef.h. In C++
       		#include <cstddef>
      and in C
       		#include <stddef.h>

    1. NULL::pointer=a pointer at nothing.
    2. size_t::data_type=used for sizes of strings, buffers, arrays,....
    3. ptrdiff_t::data_type=number that results from subtracting one pointer from another one.
    4. wchar_t::data_type=wide characters.
    5. offsetof::size_t=How far from the start of a struct is a field?.


      AKA assert.h. In C++
       		#include <cassert>
      and in C
       		#include <assert.h>
    6. assert(b)::statement=test b and if zero prints out expression, line, etc before aborting the program.

      I use <cassert> for two purposes. First as a simple way to reject bad data handed to a function -- in C++ it is better to throw an exception.

       		int mySqrt(int x) { assert (x>=0); ...}
      Second, to write quick unit tests of classes and functions in a simple form of Test Driven Development.
       		int main(){  assert (mySqrt(0)==0); ...}

    7. NDEBUG::=No Debug, #defined to turn off asserts.

      cmath -- lots of elementary functions and a constant.

      HUGE_VAL, acos, asin, atan, atan2, cos, sin, tan, cosh, sinh, tanh, exp, frexp, ldexp, log, log10, modf, pow, sqrt, ceil, fabs, floor,fmod [click here [socket symbol] if you can fill this hole]


      [click here [socket symbol] if you can fill this hole]

      To Be Done

      C: stdarg.h, time.h, signal.h, locale.h

      Definitions from the C++ Standard

    8. char::data_type=the 8 bit character set avaliable on the computer in use.
    9. bool::data_type=data that is true or false and is used in conditions.

    . . . . . . . . . ( end of section Some Standard C++ function libraries) <<Contents | End>>