Last modified on 14 October 2011, at 19:06

C++ Programming/headers

C standard headersEdit

These standard headers define functions that were originally defined in the C programming language. They make it much easier to port C code to C++.

These are only some of the many C++'s Standard Headers.

cctypeEdit

#include <cctype>

int isalnum(int c);
int isalpha(int c);
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isspace(int c);
int isprint(int c);
int isupper(int c);

cstringEdit

These cstring functions are almost never used by C++ programmers -- we use the String class instead.

#include <cstring>

size_t strlen(char* str);
char* strcpy(char* dest, char* src);
char* strncpy(char* dest, char* src, size_t length);
int strcmp(const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t length);
char* strtok(char* str, const char* delim);
char* strchr(const char* str, int c);
char* strstr(const char* str, const char* within);

ctimeEdit

#include <ctime>

clock_t clock(void);
double difftime(time_t t1, time_t t0);
time_t mktime(struct tm *timeptr);
time_t time(time_t *timer);
char *asctime(struct tm *timeptr);
char *ctime(const time_t *timer);
struct tm *gmtime(const time_t *timer);
struct tm *localtime(const time_t *timer);
size_t strftime(char * s, size_t maxsize, const char * format, struct tm * timeptr);
clock_t clock(void);
double difftime(time_t t1, time_t t0);
time_t mktime(struct tm *timeptr);
time_t time(time_t *timer);
char *asctime(struct tm *timeptr);
char *ctime(const time_t *timer);
struct tm *gmtime(const time_t *timer);
struct tm *localtime(const time_t *timer);
size_t strftime(char * s, size_t maxsize, const char * format, struct tm * timeptr);

cmathEdit

These cmath functions are heavily used in many kinds of physics simulations -- such as realistic video games, finite element analysis, etc.

 #include <cmath>

See the book sections regarding Standard C Library Math or the C Programming wikibook Further math page for details on the trig functions and other floating-point functions implemented in this library.

climitsEdit

This header lists the maximum and minimum values for all the primitive data types used in C++.

 #include <climits>

Corresponds to the C language "limits.h".

See C Programming wikibook pages regarding the C99 Reference, and it's Reference table of Standard Headers.