C Library Functions

`int isalnum(int n)` |
Returns a nonzero value if n is a letter of a decimal digit. |

`int isalpha(int n)` |
Returns a nonzero value if n is a letter. |

`int iscntrl(int n)` |
Returns a nonzero value if n is a delete character or an ordinary control character. |

`int isdigit(int n)` |
Returns a nonzero value if n is a decimal digit. |

`int isgraph(int n)` |
Returns a nonzero value if n is a printing character other than a space. |

`int islower(int n)` |
Returns a nonzero value if n is a lower case letter. |

`int isprint(int n)` |
Returns a nonzero value if n is a printing character. |

`int ispunct(int n)` |
Returns a nonzero value if n is a punctuation character. |

`int isspace(int n)` |
Returns a nonzero value if n is a space, tab, carriage return, new line, vertical tab, or form feed character. |

`int isupper(int n)` |
Returns a nonzero value if n is an upper case letter. |

`int isxdigit(int n)` |
Returns a nonzero value if n is a hexadecimal digit. |

`int tolower(int n)` |
Returns the coresponding lower-case letter if n is an upper-case letter. Otherwise, n is returned unchanged. |

`int toupper(int n)` |
Returns the coresponding upper-case letter if n is a lower-case letter. Otherwise, n is returned unchanged. |

`double acos(double x)` |
Returns the arc cosine in radians of x (x must be in the range -1 to 1). |

`double asin(double x)` |
Returns the arc sine in radians of x (x must be in the range -1 to 1). |

`double atan(double x)` |
Returns the arc tangent in radians of x. |

`double atan2(double x1, double x2)` |
Returns the arc tangent in radians of x1 / x2. |

`double atof(const char *s)` |
Returns the double value represented in the character string s. |

`double ceil(double x)` |
Returns the minimum integer (as a double) greater than or equal to x. |

`double cos(double x)` |
Returns the cosine of x (x in radians). |

`double cosh(double x)` |
Returns the hyperbolic cosine of x. |

`double exp(double x)` |
Returns e to the power of x. |

`double fabs(double x)` |
Returns the absolute value of x. |

`double floor(double x)` |
Returns the maximum integer (as a double) less than or equal to x. |

`double fmod(double x1, double x2)` |
Returns x1 modulo x2. |

`double frexp(double x, int *n)` |
Returns the base-2 mantissa of x, and stores the exponent in n. |

`long labs(long n)` |
Returns the absolute value of n. |

`double ldexp(double x, int n)` |
Returns x times 2 to the power of n. |

`double log(double x)` |
Returns the natural logarithm of x. |

`double log10(double x)` |
Returns the base-10 logarithm of x. |

`double frexp(double x, double *n)` |
Returns the fractional part of x, and stores the integer part in n. |

`double pow(double x1, double x2)` |
Returns x1 to the power of x2. |

`double sin(double x)` |
Returns the sine of x (x in radians). |

`double sinh(double x)` |
Returns the hyperbolic sine of x. |

`double sqrt(double x)` |
Returns the square root x. |

`double tan(double x)` |
Returns the tangent of x (x in radians). |

`double tanh(double x)` |
Returns the hyperbolic tangent of x. |

`void abort()` |
Terminates the program and displays an error message. |

`int abs(int x)` |
Returns the absolute value of x. |

`int atexit(void (*func)(void))` |
Sets the function, pointed to by func, to be called upon normal program termination. Returns zero if successful, or a nonzero value if unsuccessful. |

`int atoi(const char *s)` |
Returns the integer represented in the string array s. |

`long atol(const char *s)` |
Returns the long integer represented in the string array s. |

`void *calloc(size_t n1, size_t n2)` |
Allocates in memory an array of n1 blocks of size n2 bytes. If successful, a pointer to the beginning of the array is returned. Otherwise, NULL is returned. |

`div_t div(int n1, int n2)` |
Divides n1 by n2, and returns the quotient and remainder in a div_t structure (components are `quot` and `rem` ). |

`void exit(int s)` |
Terminates a program with the status value s. |

`void free(void *p)` |
Deallocates the memory area pointed to by p that was previously allocated by a call to `calloc` , `malloc` or `realloc` . |

`char *getenv(const char *s)` |
Returns the string array associated with the environment variable named in string array s. If unsuccessful, NULL is returned |

`ldiv_t ldiv(long n1, long n2)` |
Divides n1 by n2, and returns the quotient and remainder in an ldiv_t structure (components are `quot` and `rem` ). |

`void *malloc(size_t n)` |
Allocates in memory an array of size n bytes. Returns a pointer to the beginning of the array if successful, or NULL if unsuccessful. |

`void qsort(void *p, size_t n, size_t s, int (*func)(const void*, const void*))` |
Sorts the array pointed to by pointer p, with n blocks of size s, using the "quicksort" algorithm based on the function pointed to by `func` . |

`int rand(void)` |
Returns the next pseudorandom number. |

`void *realloc(void *p, size_t n)` |
Allocates in memory an array of size n bytes and copies up to n bytes from the array pointed to by p to the new array. Returns a pointer to the beginning of the new array, or NULL if unsuccessful. |

`void srand(unsigned int s)` |
Initializes the pseudorandom number generator using the seed s. |

`double strtod(const char *s, char **p)` |
Returns the double value represented in the string array s. If p is not NULL, a pointer to the first character in s that terminated the evaluation is returned in *p. |

`long strtol(const char *s, char **p, int b)` |
Returns the long integer value represented in the string array s in the numerical base b. If p is not NULL, a pointer to the first character in s that terminated the evaluation is returned in *p. |

`long strtoul(const char *s, char **p, int b)` |
Returns the unsigned long integer value represented in the string array s in the numerical base b. If p is not NULL, a pointer to the first character in s that terminated the evaluation is returned in *p. |

`int system(const char *s)` |
Executes the operating system command in the string array s. |

`void clearerr(FILE *f)` |
Sets the error and end-of-file indecators of the file f to zero. |

`int fclose(FILE *f)` |
Closes the file f. Returns a nonzero value if successful, or zero if unsuccessful. |

`int feof(FILE *f)` |
Returns a nonzero value if end-of-file is detected in file f. Otherwise zero is returned |

`int ferror(FILE *f)` |
Returns a nonzero value if an error is detected in file f. Otherwise zero is returned. |

`int fflush(FILE *f)` |
Flushes file f and writes any remaining characters to the associated file. Returns a nonzero value if successful, or zero if unsuccessful. |

`int fget(FILE *f)` |
Returns the next available character in file f, or EOF if unsuccessful. |

`int fgetpos(FILE *f, fpos_t *p)` |
Stores in p the file pointer in file f. Returns a nonzero value if successful, or zero if unsuccessful. |

`char *fgets(char *s, int n, FILE *f)` |
Stores in the character array s the next n-1 characters in file f, or to a new line character if one is encountered. Returns the pointer s, or NULL of unsuccessful. |

`FILE *fopen(const char *s, const char *m)` |
Opens the file named in the character string s, using the access mode specified in the character string m. Returns a pointer to the FILE struct, or NULL if the open was unsuccessful. |

`int fprintf(FILE *f, const char *s [, args])` |
Writes to file f using the format string s along with any arguments (`args` ) listed. Returns the number of characters that were written. |

`int fputc(int c, FILE *f)` |
Writes to file f the character c. Returns the character c if successful, or EOF if unsuccessful. |

`int fputs(const char *s, FILE *f)` |
Writes to file f the character string s. Returns the zero if successful, or a nonzero value if unsuccessful. |

`size_t fread(void *p, size_t n1, size_t n2, FILE *f)` |
Reads from file f up to n2 blocks of size n1 bytes, and stores them in the array beginning at pointer p. Returns the number of if successful, or EOF if unsuccessful. |

`FILE *freopen(char *s, char *m, FILE *f)` |
Closes the file associated with f, if it exists and is open, and reassociates f with the file named in the character string s. The file is opened using the access mode specified in the character string m. Returns a pointer to the FILE struct, or NULL if the open was unsuccessful. |

`int fscanf(FILE *f, const char *s [, ptrs])` |
Reads from file f using the format string s along with any variable pointers (`ptrs` ) listed. Returns the number of characters that were read. |

`int fseek(FILE *f, long p, int m)` |
Moves the position of the file pointer in file f a distance of p bytes relative to the starting point indicated by mode m (SEEK_SET = from beginning of file, SEEK_CUR = from current pointer position, SEEK_END = from end of file). Returns a nonzero value if successful, or zero if unsuccessful. |

`int fsetpos(FILE *f, long p)` |
Moves the position of the file pointer in file f to byte position p. Returns a nonzero value if successful, or zero if unsuccessful. |

`long ftell(FILE *f)` |
Returns the current byte position of the file pointer in file f, or -1 if unsuccessful. |

`int fwrite(void *p, size_t n1, size_t n2, FILE *f)` |
Reads from file f up to n2 blocks of size n1 bytes, and stores them in the array beginning at pointer p. Returns the character c if successful, or EOF if unsuccessful. |

`int getc(FILE *f)` |
Returns as an integer the ASCII code of the next character in file f. |

`int getchar()` |
Returns as an integer the ASCII code of the next available character entered at the keyboard (`stdin` ). |

`char *gets(char *s)` |
Reads a string of characters from the keyboard (`stdin` ), up to, but not including a newline character, and stores them in the string array s. Returns a pointer to s, or NULL if unsuccessful. |

`int printf(const char *s [, args])` |
Writes to standard output using the format string s along with any arguments (`args` ) listed. Returns the number of characters that were written. |

`int putc(char c, FILE *f)` |
Writes to file f the character c. Returns c if successful, or EOF if unsuccessful. |

`int putchar(char c)` |
Writes to standard output the character c. Returns c if successful, or EOF if unsuccessful. |

`int puts(const char *s)` |
Writes to standard output the string array s. Returns zero if successful, or a nonzero value if unsuccessful. |

`int remove(const char *s)` |
Deletes the file specified in the string array s. Returns zero if successful, or a nonzero value if unsuccessful. |

`int rename(const char *s1, const char *s2)` |
Renames the file specified in the string array s1 to the name specified in the string array s2. Returns zero if successful, or a nonzero value if unsuccessful. |

`int rewind(FILE *f)` |
Sets the file pointer in file f to the beginning of the file. Returns zero if successful, or a nonzero value if unsuccessful. |

`int scanf(const char *s [, ptrs])` |
Reads from standard input using the format string s along with any variable pointers (`ptrs` ) listed. Returns the number of characters that were read. |

string | read | write | create | replace | append |
---|---|---|---|---|---|

r | yes | no | no | no | no |

w | no | yes | yes | yes | no |

a | no | no | yes | no | yes |

r+ | yes | yes | no | no | no |

w+ | yes | yes | yes | yes | no |

a+ | yes | no | yes | no | yes |