Both
Unix and
C were created at
AT&T's Bell Laboratories in the late 1960s and early 1970s. During the 1970s the C programming language became increasingly popular. Many universities and organizations began creating their own variations of the language for their own projects. By the beginning of the 1980s compatibility problems between the various C implementations became apparent. In 1983 the
American National Standards Institute (ANSI) formed a committee to establish a standard implementation of C known as "ANSI C". Part of the resulting standard was the
ANSI C standard library.
The ANSI C standard library consists of 18 C header files which can be included into a programmer's project with a single statement. Each header file contains one or more functions, function prototypes, data type definitions and macros. The contents of these header files follows.
for enforcing assertions when functions execute
- void assert(int expression);
for classifying characters
- 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 isprint(int c);
- int ispunct(int c);
- int isspace(int c);
- int isupper(int c);
- int isxdigit(int c);
- int tolower(int c);
- int toupper(int c);
for testing error codes reported by library functions
for testing floating-point type properties
- FLT-RADIX
- FLT-ROUNDS
- FLT-DIG
- FLT-EPSILON
- FLT-MANT-DIG
- FLT-MAX
- FLT-MAX-EXP
- FLT-MIN
- FLT-MIN-EXP
- DBL-DIG
- DBL-EPSILON
- DBL-MANT-DIG
- DBL-MAX
- DBL-MAX-EXP
- DBL-MIN
- DBL-MIN-EXP
for programming in ISO 646 variant character sets
for testing integer type properties
- CHAR-BIT
- CHAR-MAX
- CHAR-MIN
- INT-MAX
- INT-MIN
- LONG-MAX
- LONG-MIN
- SCHAR-MAX
- SCHAR-MIN
- SHRT-MAX
- SHRT-MIN
- UCHAR-MAX
- UCHAR-MIN
- UINT-MAX
- ULONG-MAX
- USHRT-MAX
for adapting to different cultural conventions
for computing common mathematical functions
- double sin(double x);
- double cos(double x);
- double tan(double x);
- double asin(double x);
- double acos(double x);
- double atan(double x);
- double atan2(double y, double x);
- double sinh(double x);
- double cosh(double x);
- double tanh(double x);
- double exp(double x);
- double log(double x);
- double log10(double x);
- double pow(double x, double y);
- double sqrt(double x);
- double ceil(double x);
- double floor(double x);
- double fabs(double x);
- double ldexp(double x, int n);
- double frexp(double x, int* exp);
- double modf(double x, double* ip);
- double fmod(double x, double y);
for executing nonlocal goto statements
- int setjmp(jmp-buf env);
- void longjmp(jmp-buf env, int val);
for controlling various exceptional conditions
- SIGABRT
- SIGFPE
- SIGILL
- SIGINT
- SIGSEGV
- SIGTERM
- void (*signal(int sig, void (*handler)(int)))(int);
- int raise(int sig);
for accessing a varying number of arguments
- void va-start(va-list ap, lastarg);
- type va-arg(va-list ap, type);
- void va-end(va-list ap);
for defining several useful types and macros
for performing input and output
- FILE
- stdin
- stdout
- stderr
- FILENAME-MAX
- FOPEN-MAX
- TMP-MAX
- FILE* fopen(const char* filename, const char* mode);
- FILE* freopen(const char* filename, const char* mode, FILE* stream);
- int fflush(FILE* stream);
- int fclose(FILE* stream);
- int remove(const char* filename);
- int rename(const char* oldname, const char* newname);
- FILE* tmpfile();
- char* tmpname(char s[L-tmpnam]);
- int setvbuf(FILE* stream, char* buf, int mode, size-t size);
- void setbuf(FILE* stream, char* buf);
- int fprintf(FILE* stream, const char* format, ...);
- int printf(const char* format, ...);
- int sprintf(char* s, const char* format, ...);
- int vfprintf(FILE* stream, const char* format, va-list arg);
- int vprintf(const char* format, va-list arg);
- int vsprintf(char* s, const char* format, va-list arg);
- int fscanf(FILE* stream, const char* format, ...);
- int scanf(const char* format, ...);
- int sscanf(char* s, const char* format, ...);
- int fgetc(FILE* stream);
- char* fgets(char* s, int n, FILE* stream);
- int fputc(int c, FILE* stream);
- char* fputs(const char* s, FILE* stream);
- int getc(FILE* stream);
- int getchar();
- char* gets(char* s);
- int putc(int c, FILE* stream);
- int putchar(int c);
- int puts(const char* s);
- int unget(int c, FILE* stream);
- size-t fread(void* ptr, size-t size, size-t nobj, FILE* stream);
- size-t fwrite(const void* ptr, size-t size, size-t nobj, FILE* stream);
- int fseek(FILE* stream, long offset, int origin);
- long ftell(FILE* stream);
- void rewind(FILE* stream);
- int fgetpos(FILE* stream, fpos-t* ptr);
- int fsetpos(FILE* stream, const fpos-t* ptr);
- void clearerr(FILE* stream);
- int feof(FILE* stream);
- int ferror(FILE* stream);
- void perror(const char* s);
for performing a variety of operations
- double atof(const char* s);
- int atoi(const char* s);
- long atol(const char* s);
- double strtod(const char* s, char** endp);
- long strtol(const char* s, char** endp, int base);
- unsigned long strtoul(const char* s, char** endp, int base);
- int rand();
- void srand(unsigned int seed);
- void* calloc(size-t nobj, size-t size);
- void* malloc(size-t size);
- void* realloc(void* p, size-t size);
- void free(void* p);
- void abort();
- void exit(int status);
- int atexit(void (*fcm)(void));
- int system(const char* s);
- char* getenv(const char* name);
- void* bsearch(const void* key, const void* base, size-t n, size-t size, int (*cmp)(const void* keyval, const void* datum));
- void qsort(void* base, size-t n, size-t size, int (*cmp)(const void*, const void*));
- int abs(int n);
- long labs(long n);
- div-t div(int num, int denom);
- ldiv-t ldiv(long num, long denom);
for manipulating several kinds of strings
- char* strcpy(char* s, const char* ct);
- char* strncpy(char* s, const char* ct, int n);
- char* strcat(char* s, const char* ct);
- char* strncat(char* s, const char* ct, int n);
- int strcmp(const char* cs, const char* ct);
- int strncmp(const char* cs, const char* ct, int n);
- char* strchr(const char* cs, int c);
- char* strrchr(const char* cs, int c);
- size-t strspn(const char* cs, const char* ct);
- size-t strcspn(const char* cs, const char* ct);
- char* strpbrk(const char* cs, const char* ct);
- char* strstr(const char* cs, const char* ct);
- size-t strlen(const char* cs);
- char* strerror(int n);
- char* strtok(char* s, const char* t);
- void* memcpy(void* s, const void* ct, int n);
- void* memmove(void* s, const void* ct, int n);
- int memcmp(const void* cs, const void* ct, int n);
- void* memchr(const char* cs, int c, int n);
- void* memset(char* s, int c, int n);
for converting between various time and date formats
- clock-t
- CLOCKS-PER-SEC
- time-t
- struct tm
- int tm-sec;
- int tm-min;
- int tm-hour;
- int tm-mday;
- int tm-mon;
- int tm-year;
- int tm-wday;
- int tm-yday;
- int tm-isdst;
- clock-t clock();
- time-t time(time-t* tp);
- double difftime(time-t time2, time-t time1);
- time-t mktime(struct tm* tp);
- char* asctime(const struct tm* tp);
- char* ctime(const time-t* tp);
- struct tm* gmtime(const time-t* tp);
- struct tm* localtime(const time-t* tp);
- size-t strftime(char* s, size-t smax, const char* fmt, const struct tm* tp);
for manipulating wide streams and several kinds of strings
for classifying wide characters