Input/output library for text and binary files (not all functions are shown here, only the most common ones).
int fclose (FILE *stream); /* Closes stream If successful, returns 0. If unsuccessful, returns EOF.*/ int feof (FILE *stream); /* Returns nonzero if end-of-file has been reached on stream */ int ferror (FILE *stream); /* Returns nonzero if an error has occurred on stream */ int fgetc (FILE *stream); /* Reads character (or EOF) from stream. If successful, returns character. If unsuccessful, returns EOF. */ int fgetchar (void); /* Reads a character (or EOF) from stdin. If successful, returns character. If unsuccessful, returns EOF. */ char *fgets (char *str, int n, FILE *stream); /* Reads a string str of at most n characters from stream. Collects input from stream until a newline character (\n) is found or at most n-1 characters are read. (if read, \n is placed in the string.) If successful, returns a pointer to the nul-terminated string str. If unsuccessful, returns NULL. */ FILE *fopen (const char *filename, const char *mode); /* Opens stream in required mode to external filename. If successful, returns pointer to the newly opened stream. If unsuccessful, returns NULL. */ int fprintf (FILE *stream, const char *format[, argument, ... ]); /* Sends formatted output to stream. Uses the same format specifiers as printf, but fprintf sends output to the specified stream. If successful, returns the number of bytes output. If unsuccessful, returns EOF. */ int fputc (int c, FILE *stream); /* Writes character c to stream. If successful, returns c. If unsuccessful, returns EOF. */ int fputchar (int c); /* Writes character c to stdout If successful, returns c. If unsuccessful, returns EOF. */ int fputs (const char *str, FILE *stream); /* Writes string str to stream. If successful, returns last character written. If unsuccessful, returns EOF. */ int fscanf (FILE *stream, const char *format[, address, ... ]); /* Performs formatted input from stream. Returns the number of input fields successfully scanned, converted, and stored; return value doesn't include unstored scanned fields. Processes input according to the format and places the results in the memory locations pointed to by the arguments. */ int getc (FILE *stream); /* Reads character (or EOF) from stream. If successful, returns character. If unsuccessful, returns EOF. */ int getchar (void); /* Reads character (or EOF) from stdin. If successful, returns the character read, after converting it to an int without sign extension. If unsuccessful, returns EOF. */ char *gets (char *str); /* Reads string str from stdin. Collects input from stdin until a newline character (\n) is found. \n is not placed in the string. If successful, returns a pointer to the nul-terminated string str. If unsuccessful, returns NULL. */ int printf (const char *format [, argument, ... ]); /* Formatted output to stdout. Processes a variable number of arguments according to the format, sending the output to stdout. If successful, returns the number of bytes output. If unsuccessful, returns EOF. */ int putc (int c, FILE *stream); /* Writes character c to stream. If successful, returns the character c. If unsuccessful, returns EOF. */ int putchar (int c); /* Writes character c on stdout. If successful, returns the character c. If unsuccessful, returns EOF. */ int puts (const char *str); /* Writes string str to stdout (and appends a newline character). If successful, returns the last character written. If unsuccessful, returns EOF. */ void rewind (FILE *stream); /* Repositions file pointer to stream's beginning. */ int scanf (const char *format [, ... ]); /* Performs formatted input from stdin. Returns the number of input fields successfully scanned, converted, and stored; return value doesn't include unstored scanned fields. Processes input according to the format and places the results in the memory locations pointed to by the arguments. */ int sprintf (char *buffer, const char *format [, argument, ... ]); /* Performs formatted output to a string buffer. If successful, returns the number of bytes output. If unsuccessful, returns EOF. */ int sscanf (const char *buffer, const char *format [, address, ... ]); /* Performs formatted input from a string buffer. Returns the number of input fields successfully scanned, converted, and stored; return value doesn't include unstored scanned fields. Processes input according to the format and places the results in the memory locations pointed to by the arguments. If sscanf attempts to read past end of buffer, the return value is EOF. */ int ungetc (int c, FILE *stream); /* Pushes the character c back into input stream, so that the next call to getc(or other stream input functions) for stream will return c again. If successful, returns c. If unsuccessful, returns EOF. */ Predefined streams automatically opened when the program is started. stdin Standard input device stdout Standard output device stderr Standard error output device Other predefined quantities FILE File control structure for streams. NULL Null pointer value. EOF value of character returned when end-of-file is encountered
String library
/* size_t is int or long, depending on the implementation */ char *strcpy (char *dest, const char *src); /* Copies string src to dest. Returns dest. */ char *strncpy (char *dest, const char *src, size_t n); /* Copies at most n chars from src to dest. If n characters are copied, no null character is appended; the contents of the dest area is not a null-terminated string. */ size_t strlen (const char *str); /* Returns length of str. */ int strcmp (const char *s1, const char *s2); /* Compares one string to another, case significant 0 if s1 = s2, < 0 if s1 < s2, > 0 if s1 > s2. */ int stricmp (const char *s1, const char *s2); /* Compares one string to another, ignoring case 0 if s1 = s2, < 0 if s1 < s2, > 0 if s1 > s2. */ char *strstr (const char *str, const char *substr); /* Returns pointer to first location of substr within str or NULL. */ char *strcat (char *s1, const char *s2); /* Appends s2 to s1. */ char *strncat (char *s1, const char *s2, size_t n); /* Appends not more than n chars from s2 to s1. */
int abs (int x); /* Returns the absolute value of an integer. */ int atexit (atexit_t func); /* Registers termination function. Returns 0 on success and nonzero on failure. */ double atof (const char *s); /* Converts a string to a floating point Returns the converted value of s, or 0 if s cannot be converted. */ int atoi (const char *s); /* Converts string to integer. Returns the converted value of the input string. If the string cannot be converted, the return value is 0. */ void exit (int status); /* Terminates program. Defined values for status are EXIT_SUCCESS Normal program termination EXIT_FAILURE Abnormal program termination Before terminating, buffered output is flushed, files are closed, and exit functions are called. */ void free (void *block); /* Frees blocks allocated with malloc. */ char *getenv (const char *name); /* Gets string from environment. On success, returns a pointer to the value associated with name or NULL if the name is not defined in the environment. */ char *itoa (int value, char *string, int radix); /* Converts an integer to a string. Returns a pointer to the target string. */ char *ltoa (long value, char *string, int radix); /* Converts a long to a string. Returns a pointer to the target string. For a decimal representation, use radix=10. For hexadecimal, use radix=16. Returns a pointer to the target string. */ void *malloc (size_t size); /* Allocates memory. size is in bytes. Returns a pointer to the newly allocated block, or NULL if not enough space exists for the new block. If size == 0, it returns NULL. */ int rand (void); /* Returns random number between 0 and RAND_MAX. */ int random (int num); /* Returns a random integer between 0 and (num-1). */ void randomize (void); /* Initializes the random number generator with a random value. It uses the time function, so you should include time.h when using this routine. */
isalnum (c) True if c is a letter or digit isalpha (c) True if c is a letter isdigit (c) True if c is a digit iscntrl (c) True if c is a delete character or ordinary control character isascii (c) True if c is a valid ASCII character isprint (c) True if c is a printable character isgraph (c) Like isprint except that the space character is excluded islower (c) True if c is a lowercase letter isupper (c) True if c is an uppercase letter ispunct (c) True if c is a punctuation character isspace (c) True if c is a space, tab, carriage return, newline, vertical tab, or form-feed isxdigit (c) True if c is a hexadecimal digit toupper (c) Converts c in the range [a-z] to characters [A-Z] tolower (c) Converts c in the range [A-Z] to characters [a-z] toascii (c) Converts c greater than 127 to the range 0-127 by clearing all but the lower 7 bits