C++ Standard Library

The C++ standard library provides a large number of library functions (under different header files) for performing common tasks.


C++ Header Files

  • cmath - declares functions for mathematical operations
  • cstdlib - usually general purpose functions
  • iostream - functions for standard I/O
  • cstring - functions to manipulate C-style string
  • cctype - functions to classify (and transform) individual characters
  • csignal - to handle signals
  • clocale - internationalization support task such as date/time formatting
  • cwctype - for classifying and transforming individual wide characters
  • cstdio - C Standard Input and Output Library
  • cwchar - to work with C wide string
  • cuchar - convert between multibyte characters and UTF-16 or UTF-32
  • csetjmp - bypass the normal function call and return discipline
  • cfenv - access floating point environment
  • ctime - functions to work with date and time

Search library function

<cmath>

Title Description
C++ pow() Computes Power a Number
C++ llrint() Rounds argument using current rounding mode
C++ remainder() Returns remainder of x/y
C++ nan() returns a quiet NaN value
C++ cosh() Returns Hyperbolic Cosine of an Angle
C++ copysign() returns num with value of first and sign of second
C++ fma() Returns Fused Multiply–Accumulate
C++ abs() returns absolute value of an argument
C++ fabs() returns absolute value of argument
C++ fdim() Returns Positive Different Between Arguments
C++ fmin() returns smallest among two given arguments
C++ fmax() returns largest among two arguments passed
C++ hypot() Returns Square Root of sum of square of Arguments
C++ nexttoward() returns next value after x in direction of y
C++ nextafter() returns next value after x in direction of y
C++ cbrt() Computes Cube Root of a Number
C++ sqrt() Computes Square Root of A Number
C++ remquo() Computer remainder and stores quotient of x/y
C++ logb() returns logarithm of |x|
C++ log1p() returns natural logarithm of x+1.
C++ scalbln() Scales x by FLT_RADIX to the power n
C++ log2() returns base2 logarithm of a number
C++ scalbn() Scales x by FLT_RADIX to the power n
C++ ilogb() returns integral part of logarithm of |x|
C++ nearbyint() Rounds argument to using current rounding mode
C++ expm1() Returns e raised to Power Minus 1
C++ ldexp() returns product of x and 2 raised to the power e
C++ frexp() breaks float to its binary significand
C++ exp2() Returns 2 raised to a Number
C++ exp() returns exponential (e) raised to a number
C++ modf() Breaks Number Into Integral and Fractional Part
C++ log10() Returns Base 10 Logarithm of a Number
C++ lrint() Rounds argument using current rounding mode
C++ rint() Rounds argument using current rounding mode
C++ llround() Rounds argument to nearest long long int value
C++ lround() Returns the long int value nearest to the argument
C++ round() Returns integral value nearest to argument
C++ trunc() Truncates the demical part of a number
C++ log() Returns Natural Logarithm of a Number
C++ atanh() returns arc hyperbolic tangent of a number
C++ asinh() returns arc hyperbolic sine of a number
C++ acosh() returns hyperbolic cosine of a number
C++ fmod() Computes floating point remainder of division
C++ tanh() returns hyperbolic tangent of an angle
C++ floor() Returns floor value of decimal number
C++ ceil() Return ceiling value of number
C++ sinh() returns hyperbolic sine of an angle
C++ acos() Returns Inverse cosine a Number
C++ atan2() Returns Inverse Tangent of a Coordinate
C++ tan() Returns Tangent of the Argument
C++ atan() Returns Inverse tangent a Number
C++ asin() Returns Inverse Sine a Number
C++ sin() Returns Sine of the Argument
C++ cos() Returns Cosine of the Argument

<cstdlib>

Title Description
C++ calloc() allocates block of memory and initializes to zero
C++ wcstombs() converts wide character string to multibyte seq
C++ mbstowcs() converts multibyte char string to wide char seq
C++ wctomb() converts wide character to a multibyte character
C++ mbtowc() converts multibyte character to a wide character
C++ mblen() determines size of a multibyte character
C++ lldiv() computes integral division of two long long int.
C++ llabs() returns absolute value of a long long int data
C++ ldiv() computes integral division of long int numbers
C++ labs() returns absolute value of long or long int number
C++ abs() returns absolute value of an integer
C++ div() computes integral quotient and remainder of number
C++ qsort() sorts array using quick-sort algorithm
C++ bsearch() performs binary search on sorted array
C++ _Exit() causes termination without cleanup tasks
C++ quick_exit() causes termination without cleaning resources
C++ getenv() returns pointer to environment variable passed
C++ at_quick_exit() registers function and calls on quick termination
C++ atexit() registers function to be called on termination
C++ realloc() reallocates a block of previously allocated memory
C++ malloc() allocates a block of unitialized memory
C++ free() deallocates a block of memory
C++ srand() seeds pseudo random number for rand()
C++ strtoull() converts string to unsigned long long int
C++ strtoll() converts string to long long int in C++
C++ atol() Converts String to Integer
C++ strtol() Converts a string to number
C++ atof() Converts String to Double
C++ strtod() returns string float to double

<iostream>

Title Description
C++ wclog writes to log stream with wide character
C++ wcerr prints to error stream as wide character type
C++ wcout displays wide characters (Unicode) to screen
C++ wcin accepts input in wide character type
C++ clog used for streaming logs
C++ cerr writes to error stream
C++ cout displays output to output device i.e monitor
C++ cin accepts input from user

<cstring>

Title Description
C++ strxfrm() transform byte string into implementation def form
C++ strcoll() compares two null terminated string
C++ strlen() returns length of given string
C++ strerror() gives description of system error code
C++ memset() copies character to beginning of string n times
C++ strtok() split string based on delimiter
C++ strstr() finds first occurrence of a substring in string
C++ strspn() gives length of maximum initial segment
C++ strrchr() searches last occurence of a character in string
C++ strpbrk() search characters in one string in another string
C++ strcspn() searches a string for characters in another string
C++ strchr() searches for character in string
C++ memchr() searches for character in string
C++ strncmp() compares two strings lexographically
C++ strcmp() compare two strings
C++ memcmp() compares two pointer objects
C++ strncat() appends string to end of another string
C++ strcat() appends copy of string to end of another string
C++ strncpy() copies character string from source to destination
C++ strcpy() copies character string from source to destination
C++ memmove() copies memory even if there is overlapping blocks
C++ memcpy() copies block of memory from source to destination

<cctype>

Title Description
C++ toupper() converts a given character to uppercase
C++ tolower() converts a given character to lowercase
C++ isxdigit() checks if given character is hexadecimal character
C++ isupper() check if given character is uppercase or not
C++ isspace() check if given character is whitespace character
C++ ispunct() check if given character is punctuation character
C++ isprint() check if given character is printable or not
C++ islower() checks if given character is lowercase
C++ isgraph() checks if given character is graphic or not
C++ isdigit() checks if given character is a digit or not
C++ iscntrl() checks if given character is control character
C++ isblank() checks if given character is a blank character
C++ isalpha() checks if given character is alphabet or not

<csignal>

Title Description
C++ raise() sends signal to the program
C++ signal() sets error handler for specifiied signal

<clocale>

Title Description
C++ localeconv() returns current locale formatting rules
C++ setlocale() sets locale information for the current program

<cwctype>

Title Description
C++ iswdigit() checks if given wide character is digit or not
C++ wctype() returns wide character classification
C++ wctrans() returns current transformation for wide character
C++ towctrans() transforms a given wide character
C++ iswctype() checks if given wide char has certain property
C++ towupper() converts given wide character to uppercase
C++ towlower() converts given wide character to lowercase
C++ iswxdigit() checks if given wide character is hexadecimal num
C++ iswupper() checks if given wide character is uppercase
C++ iswspace() checks if given wide character is wide whitespace
C++ iswpunct() checks if given wide character is punctuation
C++ iswprint() checks if given wide character can be printed
C++ iswlower() checks if given wide character is lowercase
C++ iswgraph() checks if wide char has graphical representation
C++ iswcntrl() checks if given wide char is control character
C++ iswblank() checks if given wide character is blank character
C++ iswalpha() checks if given wide character is an alphabet
C++ iswalnum() checks if given wide character is alphanumeric

<cstdio>

Title Description
C++ getc() reads next character from input stream
C++ fseek() sets file position indicator for given file stream
C++ ungetc() push previously read character back to the stream
C++ vsscanf() read data from a string buffer
C++ vscanf() read data from stdin
C++ vfscanf() read data from a file stream
C++ freopen() opens a new file with stream associated to another
C++ fflush() flushes any buffered data to the respective device
C++ setvbuf() change or specify buffering mode and buffer size
C++ perror() prints error to stderr
C++ ferror() checks for errors in given stream
C++ feof() function checks if file stream EOF has been reached or not
C++ clearerr() resets error flags and EOF indicator for stream
C++ rewind() sets file position to beginning of stream
C++ ftell() returns current position of file pointer
C++ fsetpos() sets stream file pointer to given position
C++ fgetpos() gets current file position
C++ fwrite() writes specified number of characters to stream
C++ fread() reads specified no. of characters from stream
C++ puts() writes string to stdout
C++ putchar() writes a character to stdout
C++ putc() writes character to given output stream
C++ gets() reads line from stdin
C++ getchar() reads next character from stdin
C++ fputs() writes string to file stream
C++ fputc() writes character to given output stream
C++ fgets() reads n number of characters from file stream
C++ fgetc() reads the next character from given input stream
C++ vsprintf() write formatted string to a string buffer
C++ vsnprintf() write formatted string to string buffer
C++ vprintf() printf but takes args from vlist instead
C++ vfprintf() write formatted string to file stream
C++ sscanf() read data from string buffer
C++ sprintf() write a formatted string to buffer
C++ snprintf() write formatted string to character string buffer
C++ scanf read data form stdin
C++ printf() write formatted string to stdout
C++ fscanf() read data from file stream
C++ fprintf() write a formatted string to file stream
C++ setbuf() sets the internal buffer to be used for I/O
C++ fopen() opens specified file
C++ fclose() closes given file stream
C++ tmpnam() generates unique filename
C++ tmpfile() creates temporary file with auto-generated name
C++ rename() renames or moves specified file
C++ remove() deletes the specified file

<cwchar>

Title Description
C++ wcscoll() compares two null terminated wide string
C++ wcstoull() converts wide string num to unsigned long long
C++ wcstoul() converts wide str of given base to unsigned long
C++ wcstoll() converts wide string of specified base to int
C++ wcsftime() converts given date and time to wide character str
C++ wmemset() copies single wide char for a certain num of time
C++ wmemmove() moves wide chars from src to dest
C++ wmemcpy() copies specified num of wide char from src to dest
C++ wmemcmp() compares wide chars of two wide strings
C++ wmemchr() searches for first occurrence of wide char
C++ wcsxfrm() transforms wide string to implementation defined
C++ wcsstr() finds first occurrence of wide substring in a str
C++ wcsspn() returns length of maximum initial segment
C++ wcsrchr() searches last occurrence of wide char in string
C++ wcspbrk() searches for set of wide char in given wide string
C++ wcsncpy() copies specified number of wide characters
C++ wcsncmp() compares specified number of wide char of strings
C++ wcsncat() appends specified num of wide char to another str
C++ wcslen() returns length of the given wide string
C++ wcscspn() returns number of wide char before first occurence
C++ wcscpy() copies wide character string from source to dest
C++ wcscmp() lexicographically compares two wide string
C++ wcschr() searches for a wide character in a wide string
C++ wcscat() appends copy of wide string to the end of another
C++ wcsrtombs() convert wide char seq to narrow multibyte char seq
C++ wctob() converts wide character to single byte character
C++ wcrtomb() convert wide character to its narrow multibyte rep
C++ mbsrtowcs() convert narrow multibyte char seq to wide char seq
C++ mbsinit() describe initial conversion state of mbstate_t obj
C++ mbrtowc() converts narrow multibyte char to wide char
C++ mbrlen() determines size in bytes of a multibyte character
C++ btowc() converts character to its wide character
C++ wcstok() returns next token in null terminated wide string
C++ wcstold() converts wide string float number to long double
C++ wcstol() converts wide string float number to long int
C++ wcstof() converts wide string float number to float
C++ wcstod() converts wide string float number to double
C++ wscanf() reads wide character from stdin
C++ wprintf() write formatted wide string to stdout
C++ vwscanf() read wide character from stdin
C++ vwprintf() write formatted wide string to stdout
C++ vswscanf() read wide character string from wide string buffer
C++ vswprintf() write formatted wide string to wide string buffer
C++ vfwscanf() read wide character string from a file stream
C++ vfwprintf() write formatted wide string to a file stream
C++ ungetwc() push previously read wide character back to stream
C++ swscanf() reads wide character from wide string buffer
C++ swprintf() write formatted wide string to wide string buffer
C++ putwchar() writes wide character to stdout
C++ putwc() writes wide character to the given output stream
C++ getwchar() reads next wide character from stdin
C++ getwc() reads next wide character from input stream
C++ fwscanf() reads wide character from file stream
C++ fwprintf() write formatted wide string to a file stream
C++ fwide() set or query orientation of given file stream
C++ fputws() writes wide string except null wide char to output
C++ fputwc() writes wide character to the given output stream
C++ fgetws() reads specified num of wide characters from stream
C++ fgetwc() reads next wide character from given input stream

<cuchar>

Title Description
C++ mbrtoc32() converts narrow multibyte char to 32 bit char
C++ mbrtoc16() converts narrow multibyte char to 16 bit char
C++ c32rtomb() converts 32 bit char to narrow multibyte char
C++ c16rtomb() converts 16 bit char to narrow multibyte char

<csetjmp>

Title Description
C++ longjmp() and setjmp() restores previously saved environment

<cfenv>

Title Description
C++ fetestexcept() tests floating point exception
C++ feupdateenv() updates floating point environment
C++ feholdexcept() saves and clear floating point status flags
C++ fesetenv() set floating point environment
C++ fesetround() set rounding direction
C++ fegetenv() store status of floating point env in an object
C++ fegetround() gets round direction mode
C++ fesetexceptflag() sets given floating point exceptions to the env
C++ fegetexceptflag() gets floating point exception flags
C++ feraiseexcept() raises floating point exceptions specified
C++ feclearexcept() attempts to clear floating point exception flags

<ctime>

Title Description
C++ strftime() converts calendar time to multibyte character str
C++ mktime() converts local calendar time to time since epoch
C++ localtime() converts given time since epoch to local time
C++ gmtime() converts given time since epoch to UTC time
C++ ctime() converts time since epoch to char representation
C++ asctime() converts calendar time to character representation
C++ time() returns current calendar time
C++ difftime() computes difference between two times in seconds
C++ clock() returns processor time consumed by program