Standard Library Functions
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 inputint printf(const char* format, ...): Send data to standard outputint fscanf(FILE* stream, const char* format, ...): Read data from a file streamint fprintf(FILE* stream, const char* format, ...): Send data to a file stream
<cstring> - C-Style Null-Terminated Strings
size_t: Non-negative integer typesize_t strlen(const char* str): The number of characters in a C-style null-terminated stringchar* strcpy(char* destination, const char* source): Copy C-style null-terminated string fromsourceaddress todestinationaddresschar* strcat(char* destination, const char* source): Concatenate C-style null-terminated string fromsourceaddress to the string at thedestinationaddressint 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 ofiint atoi(const char* str): Convert C-style null-terminated string (str) to an integerint rand(): Generate a random number
<cmath> - Numerics
double abs(double x): Absolute value ofxfloat abs(float x): Absolute value ofxdouble pow(double base, double exponent): Raisesbaseto the power ofexponentdouble sqrt(double x): Square root ofx
<cctype> - Character Handling
int toupper(int c): Convertscto upper caseint tolower(int c): Convertscto lower caseint isupper(int c): Iscupper case?int islower(int c): Isclower case?int isalpha(int c): Iscalphabetic?int isdigit(int c): Isca numeric digit?
Input Output Library
<iostream> - Standard Input Output Objects
streamsize: Integer typefmtflags: Format flags typechar fill(char c): Set fill character tocfmtflags setf(fmtflags f): Set format toffmtflags unsetf(fmtflags f): Unset format forfstreamsize width(streamsize w): Set field width towstreamsize precision(streamsize p): Set floating-point precision topbool good() const: Good bit is setbool eof() const: End of file bit is setbool fail() const: Fail file bit is setbool bad() const: Bad bit is setbool eof() const: End of file bit is setvoid clear(): Set error state to good
<iomanip> - Parametric Manipulators
setfill(char c): Set fill character tocsetw(int w): Set field width towsetprecision(int p): Set floating-point precision top
<fstream> - File Input Output Objects
void open(const char* f, ...): Open file namedfand associate it with the current objectvoid close(): Close file associated with current object