http://www.oocities.org/SiliconValley/Peaks/8778/TAU_advprog.html

2.14 ANSI C Library

Listed below are the most important of the ANSI C standard library functions.

The header file where related definitions are stored are given (these may vary on some systems so check local reference manuals).

A brief description is included with all parameter types. More info can be obtained from online help or reference manuals.

2.14.1 Buffer Manipulation

#include <memory.h>
void *memchr (void *s, int c, size_t n) Search for a character in a buffer
int memcmp (void *s1, void *s2, size_t n) Compare two buffers
void *memcpy (void *dest, void *src, size_t n) Copy one buffer into another
void *memmove (void *dest, void *src, size_t n) Move a number of bytes from one buffer to another
void *memset (void *s, int c, size_t n) Set all bytes of a buffer to a given character

2.14.2 Character Classification and Conversion

#include <ctype.h> 
int isalnum(int c) True if c is alphanumeric.
int isalpha(int c) True if c is a letter.
int isascii(int c) True if c is ASCII.
int iscntrl(int c) True if c is a control character.
int isdigit(int c) True if c is a decimal digit.
int isgraph(int c) True if c is a graphical character.
int islower(int c) True if c is a lowercase letter.
int isprint(int c) True if c is a printable character.
int ispunct (int c) True if c is a punctuation character.
int isspace(int c) True if c is a space character.
int isupper(int c) True if c is an uppercase letter.
int isxdigit(int c) True if c is a hexadecimal digit.
int toascii(int c) Convert c to ASCII.
int tolower(int c) Convert c to lowercase.
int toupper(int c) Convert c to uppercase.

2.14.3 Data Conversion

#include <stdlib.h> 
double atof(char *string) Convert string to floating point value.
int atoi(char *string) Convert string to an integer value.
int atol(char *string) Convert string to a long integer value.
char *itoa(int value, char *string, int radix) Convert an integer value to a string using given radix.
char *ltoa(long value, char *string, int radix) Convert long integer to string in a given radix.
double strtod(char *string, char *endptr) Convert string to a floating point value.
long strtol(char *string, char *endptr, int radix) Convert string to a long integer using a given radix.
unsigned long strtoul(char *string, char *endptr, int radix) Convert string to unsigned long.

2.14.4 Directory Manipulation

#include <dir.h> 
int chdir(char *path) Change current directory to given path.
char *getcwd(char *path, int numchars) Returns name of current working directory.
int mkdir(char *path) Create a directory u sing given path name.
int rmdir(char *path) Delete a specified directory.

2.14.5 File Manipulation

#include <sys/stat.h>
#include <sys/types.h> 
int chmod(char *path, int pmode) Change permission settings of a file.
int fstat(int handle, struct stat *buffer) Get file status information.
int remove(char *path) Delete a named file.
int rename(char *oldname, char *newname) rename a file.
int stat(char *path, struct stat *buffer) Get file status information of named file.
unsigned umask(unsigned pmode) Set file permission mask.

2.14.6 Input and Output (Stream I/O)

#include <stdio.h> 
void clearerr(FlLE *file_pointer) Clear error indicator of stream,
int fclose(FlLE *file_pointer) Close a file,
int feof(FlLE *file_pointer) Check if end of file occurred on a stream.
int ferror(FlLE *file_pointer) Check if any error occurred during file I/0.
int fflush(FlLE *file_pointer) Write out (flush) buffer to file.
int fgetc(FlLE *file_pointer) Get a character from a stream.
int fgetpos(FlLE *file_pointer, fpos_t current_pos) Get the current position in a stream.
char *fgets(char *string, int maxchar, FILE *file_pointer) Read a string from a file.
FILE *fopen(char *filename, char *access_mode) Open a file for buffered I/0.
int fprintf(FlLE *file_pointer, char *format_string, args) Write formatted output to a file,
int fputc(int c, FILE *file_pointer) Write a character to a stream.
int fputchar(int c) Write a character to stdout.
int fputs(char *string, FILE *file_pointer) Write a string to a stream.
size_t fread(char *buffer, size_t size size_t count, FILE *file_pointer) Read unformatted data from a stream into a buffer.
FILE *freopen(char *filename, char *access mode, FILE *file_pointer) Reassign a file pointer to a different file.
int fscanf(FlLE *file_pointer, char *format string, args) Read formatted input from a stream.
int fseek(FlLE *file_pointer, long offset, int origin) Set current position in file to a new location.
int fsetpos(FlLE *file pointer, fpos_t *current pos) Set current position in file to a new location.
long ftell(FlLE *file_pointer) Get current location in file.
size_t fwrite(char *buffer, size_t size, size_t count FILE *file_pointer) Write unformatted data from a buffer to a stream.
int getc(FlLE *file_pointer) Read a character from a stream.
int getchar(void) Read a character from stdin.
char *gets(char *buffer) Read a line from stdin into a buffer.
int printf(char *format _string, args) Write formatted output to stdout.
int putc(int c, FILE *file_pointer) Write a character to a stream.
int putchar(int c) Write a character to stdout.
int puts(char *string) Write a string to stdout.
void rewind(FlLE *file_pointer) Rewind a file.
int scanf(char *format_string, args) Read formatted input from stdin.
void setbuf(FlLE *file_pointer, char *buffer) Set up a new buffer for the stream.
int setvbuf(FlLE *file_pointer, char *buffer, int buf_type, size_t buf size) Set up new buffer and control the level of buffering on a stream.
int sprintf(char *string, char *format_string, args) Write formatted output to a string.
int sscanf(char *buffer, char *format_string, args) Read formatted input from a string.
FILE *tmpfile(void) Open a temporary file.
char *tmpnam(char *file_name) Get temporary file name.
int ungetc(int c, FILE *file_pointer) Push back character into stream' s buffer

2.14.7 Mathematics

#include <math.h>
int abs (int n) Get absolute value of an integer.
double acos(double x) Compute arc cosine of x.
double asin(double x) Compute arc sine of x.
double atan(double x) Compute arc tangent of x.
double atan2(double y, double x) Compute arc tangent of y/x.
double ceil(double x) Get smallest integral value that exceeds x.
double cos(double x) Compute cosine of angle in radians.
double cosh(double x) Compute the hyperbolic cosine of x.
div_t div(int number, int denom) Divide one integer by another.
double exp(double x Compute exponential of x.
double fabs (double x ) Compute absolute value of x.
double floor(double x) Get largest integral value less than x.
double fmod(double x, double y) Divide x by y with integral quotient and return remainder.
double frexp(double x, int *expptr) Breaks down x into mantissa and exponent of no.
long labs(long n) Find absolute v alue of long integer n.
double ldexp(double x, int exp) Reconstructs x out of mantissa and exponent of two.
ldiv_t ldiv(long number, long denom) Divide one long integer by another.
double log(double x) Compute log(x).
double log10 (double x ) Compute log to the base 10 of x.
double modf(double x, double *intptr) Breaks x into fractional and integer parts.
double pow (double x, double y) Compute x raised to the power y.
int rand (void) Get a random integer between 0 and 32.
int random(int max_num) Get a random integer between 0 and max_num.
void randomize(void) Set a random seed for the random number generator.
double sin(double x) Compute sine of angle in radians.
double sinh(double x) Compute the hyperbolic sine of x.
double sqrt(double x) Compute the square root of x.
void srand(unsigned seed) Set a new seed for the random number generator (rand).
double tan(double x) Compute tangent of angle in radians.
double tanh(double x) Compute the hyperbolic tangent of x.

2.14.8 Memory Allocation

#include <malloc.h> 
void *calloc(size_t num elems, size_t elem_size) Allocate an array and initialize all elements to zero.
void free(void *mem address) Free a block of memory.
void *malloc(size_t num bytes) Allocate a block of memory.
void *realloc(void *mem address, size_t news i ze) Reallocate (adjust size) a block of memory.

2.14.9 Process Control

#include <stdlib.h>
void abort(void) Abort a process.
int execl(char *path, char *argO, char *arg1,..., NULL) Launch a child process (pass command line).
int execlp(char *path, char *argO, char *arg1,..., NULL) Launch child (use PATH pass command line).
int execv(char *path, char *argv[]) Launch child (pass argument vector).
int execvp(char *path, char *argv[]) Launch child (use PATH, pass argument vector).
void exit(int status) Terminate process after flushing all buffers.
char *getenv(char *varname) Get definition of environment variable,
void perror(char *string) Print error message corresponding to last system error.
int putenv(char *envstring) Insert new definition into environment table.
int raise(int signum) Generate a C signal (exception).
void (*signal(int signum, void(*func)(jnt signum [, int subcode])))(int signum) Establish a signal handler for signal number signum.
int system(char *string) Execute an operating system command.

2.14.10 Searching and Sorting

#include <stdlib.h>
void *bsearch(void *key, void *base, size_t num, size_t width, int (*compare)(void *elem1, void *elem2)) Perform binary search.
void qsort(void *base, size_t num, size_t width, int (*compare)(void *elem1, void *elem2)) Use the quicksort algorithm to sort an array.

2.14.11 String Manipulation

#include <string.h>
char *stpcpy (char *dest, char *src) Copy one string into another.
int strcmp(char *string1, char *string2) Compare string1 and string2 to determine alphabetic order.
char *strcpy(char *string1, char *string2) Copy string2 to stringl.
char *strerror(int errnum) Get error message corresponding to specified error number.
int strlen(char *string) Determine the length of a string.
char *strncat(char *string1, char *string2, size_t n) Append n characters from string2 to stringl.
int strncmp(char *string1, char *string2, size_t n) Compare first n characters of two strings.
char *strncpy(char *string1, char *string2, size_t n) Copy first n characters of string2 to stringl.
char *strnset(char *string, int c, size _t n) Set first n characters of string to c.
char *strrchr(char *string, int c) Find last occurrence of character c in string.

2.14.12 Time

#include <time.h>
char *asctime (struct tm *time) Convert time from struct tm to string.
clock_t clock(void) Get elapsed processor time in clock ticks.
char *ctime(time_t *time) Convert binary time to string.
double difftime(time_t time2, time_t time1) Compute the difference between two times in seconds.
struct tm *gmtime (time_t *time) Get Greenwich Mean Time (GMT) in a tm structure.
struct tm *localtime(time_t *time) Get the local time in a tm structure.
time_t time(time_t *timeptr) Get current times as seconds elapsed since 0 hours GMT 1/1/70.