Appendices

Standard Library Functions


C Library | Input Output Library


The prototypes for the some common functions in the C++ standard library are listed below.  These prototypes and the functions definitions are declared within the std namespace.  To access one of these functions, we #include its parent header file and either expose the entire namespace (using namespace std;) or add the std:: prefix to the function identifier.


C Library

<cstdio> - Standard and File Input Output

  • int scanf(const char* format, ...) - read data from standard input
  • int printf(const char* format, ...) - send data to standard output
  • int fscanf(FILE* stream, const char* format, ...) - read data from a file stream
  • int fprintf(FILE* stream, const char* format, ...) - send data to a file stream

<cstring> - C-Style Null-Terminated Strings

  • size_t - non-negative integer type
  • size_t strlen(const char* str) - the number of characters in a C-style null-terminated string
  • char* strcpy(char* destination, const char* source) - copy C-style null-terminated string from source address to destination address
  • char* strcat(char* destination, const char* source) - concatenate C-style null-terminated string from source address to the string at the destination address
  • int strcmp(const char* str1, const char* str2) - compare C-style null-terminated strings at two addresses

<cstdlib> - General Utilities

  • int abs(int i) - absolute value of i
  • int atoi(const char* str) - convert C-style null-terminated string (str) to an integer
  • int rand() - generate a random number

<cmath> - Numerics

  • double abs(double x) - absolute value of x
  • float abs(float x) - absolute value of x
  • double pow(double base, double exponent) - raises base to the power of exponent
  • double sqrt(double x) - square root of x

<cctype> - Character Handling

  • int toupper(int c) - converts c to upper case
  • int tolower(int c) - converts c to lower case
  • int isupper(int c) - is c upper case?
  • int islower(int c) - is c lower case?
  • int isalpha(int c) - is c alphabetic?
  • int isdigit(int c) - is c a numeric digit?

Input Output Library

<iostream> - Standard Input Output Objects

  • streamsize - integer type
  • fmtflags - format flags type
  • char fill(char c) - set fill character to c
  • fmtflags setf(fmtflags f) - set format to f
  • fmtflags unsetf(fmtflags f) - unset format for f
  • streamsize width(streamsize w) - set field width to w
  • streamsize precision(streamsize p) - set floating-point precision to p
  • bool good() const - goo bit is set
  • bool eof() const - end of file bit is set
  • bool fail() const - fail file bit is set
  • bool bad() const - bad bit is set
  • bool eof() const - end of file bit is set
  • void clear() - set error state to good

<iomanip> - Parametric Manipulators

  • setfill(char c) - set fill character to c
  • setw(int w) - set field width to w
  • setprecision(int p) - set floating-point precision to p

<fstream> - File Input Output Objects

  • void open(const char* f, ...) - open file named f and associate it with the current object
  • void close() - close file associated with current object




   Printer Friendly Version of this Page print this page     Top  Go Back to the Top of this Page
Previous Reading  Previous: Bibliography Next: ASCII Collating Sequence   Next Reading


  Designed by Chris Szalwinski   Copying From This Site   

Creative Commons License