C Standard Library Function List
C Standard Library Function List
asctime time.h char *asctime(const struct tm Converts the time that is stored
*time); as a structure to a character
string.
atan2 math.h double atan2(double y, double Calculates the arc tangent of y/x.
x);
atol stdlib.h long int atol(const char *string); Converts string to a long integer.
calloc stdlib.h void *calloc(size_t num, size_t Reserves storage space for an
size); array of num elements, each of
size size, and initializes the values
of all elements to 0.
catopen6 nl_types.h nl_catd catopen (const char Opens a message catalog, which
*name, int oflag); must be done before a message
can be retrieved.
clearerr stdio.h void clearerr(FILE *stream); Resets the error indicators and
the end-of-file indicator for
stream.
ctime64.)
div stdlib.h div_t div(int numerator, int Calculates the quotient and
denominator); remainder of the division of
numerator by denominator.
erfc math.h double erfc(double x); Calculates the error function for
large values of x.
feof stdio.h int feof(FILE *stream); Tests whether the end-of-file flag
is set for a given stream.
fflush1 stdio.h int fflush(FILE *stream); Writes the contents of the buffer
associated with the output
stream.
fgetpos1 stdio.h int fgetpos(FILE *stream, fpos_t Stores the current position of the
*pos); file pointer associated with
stream into the object pointed to
by pos.
fgets1 stdio.h char *fgets(char *string, int n, Reads a string from the input
FILE *stream); stream.
fgetws6 stdio.h wchar_t *fgetws(wchar_t *wcs, Reads wide characters from the
wchar.h int n, FILE *stream); stream into the array pointed to
by wcs.
fprintf stdio.h int fprintf(FILE *stream, const Formats and prints characters
char *format-string, arg-list); and values to the output stream.
fputc1 stdio.h int fputc(int c, FILE *stream); Prints a character to the output
stream.
fputs1 stdio.h int fputs(const char *string, FILE Copies a string to the output
*stream); stream.
fputwc6 stdio.h wint_t fputwc(wchar_t wc, FILE Converts the wide character wc
wchar.h *stream); to a multibyte character and
writes it to the output stream
pointed to by stream at the
current position.
fread stdio.h size_t fread(void *buffer, size_t Reads up to count items of size
size, size_t count, FILE *stream); length from the input stream,
and stores them in buffer.
fscanf stdio.h int fscanf(FILE *stream, const Reads data from stream into
char *format-string, arg-list); locations given by arg-list.
fseek1 stdio.h int fseek(FILE *stream, long int Changes the current file position
offset, int origin); associated with stream to a new
location.
fsetpos1 stdio.h int fsetpos(FILE *stream, const Moves the current file position to
fpos_t *pos); a new location determined by
pos.
ftell1 stdio.h long int ftell(FILE *stream); Gets the current position of the
file pointer.
fwide6 stdio.h int fwide(FILE *stream, int Determines the orientation of the
wchar.h mode); stream pointed to by stream.
fwprintf6 stdio.h int fwprintf(FILE *stream, const Writes output to the stream
wchar.h wchar_t *format, arg-list); pointed to by stream.
fwrite stdio.h size_t fwrite(const void *buffer, Writes up to count items of size
size_t size,size_t count, FILE length from buffer to stream.
*stream);
fwscanf6 stdio.h int fwscanf(FILE *stream, const Reads input from the stream
wchar.h wchar_t *format, arg-list) pointed to by stream.
System
Function Include File Function Prototype Description
getc1 stdio.h int getc(FILE *stream); Reads a single character from the
input stream.
gets stdio.h char *gets(char *buffer); Reads a string from stdin, and
stores it in buffer.
isascii4 ctype.h int isascii(int c); Tests if c is within the 7-bit US-
ASCII range.
iswalnum4 wctype.h int iswalnum (wint_t wc); Checks for any alphanumeric
wide character.
iswalpha4 wctype.h int iswalpha (wint_t wc); Checks for any alphabetic wide
character.
iswblank4 wctype.h int iswblank (wint_t wc); Checks for any blank or tab wide
character.
iswcntrl4 wctype.h int iswcntrl (wint_t wc); Tests for any control wide
character.
iswctype4 wctype.h int iswctype(wint_t wc, wctype_t Determines whether or not the
wc_prop); wide character wc has the
property wc_prop.
iswdigit4 wctype.h int iswdigit (wint_t wc); Checks for any decimal-digit wide
character.
System
Function Include File Function Prototype Description
iswgraph4 wctype.h int iswgraph (wint_t wc); Checks for any printing wide
character except for the wide-
character space.
iswlower4 wctype.h int iswlower (wint_t wc); Checks for any lowercase wide
character.
iswprint4 wctype.h int iswprint (wint_t wc); Checks for any printing wide
character.
iswpunct4 wctype.h int iswpunct (wint_t wc); Test for a wide non-
alphanumeric, non-space
character.
iswspace4 wctype.h int iswspace (wint_t wc); Checks for any wide character
that corresponds to an
implementation-defined set of
wide characters for which
iswalnum is false.
iswupper4 wctype.h int iswupper (wint_t wc); Checks for any uppercase wide
character.
iswxdigit4 wctype.h int iswxdigit (wint_t wc); Checks for any hexadecimal digit
character.
labs stdlib.h long int labs(long int n); Calculates the absolute value of
n.
ldexp math.h double ldexp(double x, int exp); Returns the value of x multiplied
by (2 to the power of exp).
ldiv stdlib.h ldiv_t ldiv(long int numerator, Calculates the quotient and
long int denominator); remainder of
System
Function Include File Function Prototype Description
numerator/denominator.
mbrlen4 wchar.h int mbrlen (const char *s, size_t Determines the length of a
n, mbstate_t *ps); multibyte character. (Restartable
version of mblen.)
mbsinit4 wchar.h int mbsinit (const mbstate_t Test state object *ps for initial
*ps); state.
System
Function Include File Function Prototype Description
mbtowc stdlib.h int mbtowc(wchar_t *pwc, const Stores the wchar_t code
char *string, size_t n); corresponding to the first n bytes
of multibyte character string into
the wchar_t character pwc.
memchr string.h void *memchr(const void *buf, Searches the first count bytes of
int c, size_t count); buf for the first occurrence of c
converted to an unsigned
character.
memcpy string.h void *memcpy(void *dest, const Copies count bytes of src to dest.
void *src, size_t count);
memmove string.h void *memmove(void *dest, Copies count bytes of src to dest.
const void *src, size_t count); Allows copying between objects
that overlap.
memset string.h void *memset(void *dest, int c, Sets count bytes of dest to a
size_t count); value c.
mktime time.h time_t mktime(struct tm *time); Converts local time into calendar
time.
nl_langinfo4 langinfo.h char *nl_langinfo(nl_item item); Retrieve from the current locale
the string that describes the
requested information specified
by item.
perror stdio.h void perror(const char *string); Prints an error message to stderr.
pow math.h double pow(double x, double y); Calculates the value x to the
power y.
printf stdio.h int printf(const char *format- Formats and prints characters
string, arg-list); and values to stdout.
putc1 stdio.h int putc(int c, FILE *stream); Prints c to the output stream.
qsort stdlib.h void qsort(void *base, size_t Performs a quick sort of an array
num, size_t width, of num elements, each of width
int(*compare)(const void bytes in size.
System
Function Include File Function Prototype Description
raise signal.h int raise(int sig); Sends the signal sig to the
running program.
realloc stdlib.h void *realloc(void *ptr, size_t Changes the size of a previously
size); reserved storage block.
regerror regex.h size_t regerror(int errcode, const Finds the description for the error
regex_t *preg, char *errbuf, code errcode for the regular
size_t errbuf_size); expression preg.
regexec regex.h int regexec(const regex_t *preg, Compares the null-ended string
const char *string, size_t string against the compiled
nmatch, regmatch_t *pmatch, regular expression preg to find a
int eflags); match between the two.
regfree regex.h void regfree(regex_t *preg); Frees any memory that was
allocated by regcomp to
implement the regular expression
preg.
scanf stdio.h int scanf(const char *format- Reads data from stdin into
string, arg-list); locations given by arg-list.
setbuf stdio.h void setbuf(FILE *stream, char Controls buffering for stream.
*buffer);
setvbuf stdio.h int setvbuf(FILE *stream, char Controls buffering and buffer size
*buf, int type, size_t size); for stream.
snprintf stdio.h int snprintf(char *outbuf, size_t Same as sprintf except that the
n, const char*, ...) function will stop after n
characters have been written to
outbuf.
sprintf stdio.h int sprintf(char *buffer, const Formats and stores characters
char *format-string, arg-list); and values in buffer.
srand stdlib.h void srand(unsigned int seed); Sets the seed for the pseudo-
random number generator.
sscanf stdio.h int sscanf(const char *buffer, Reads data from buffer into the
const char *format, arg-list); locations given by arg-list.
strchr string.h char *strchr(const char *string, Locates the first occurrence of c
int c); in string.
strcmp string.h int strcmp(const char *string1, Compares the value of string1 to
const char *string2); string2.
strcoll string.h int strcoll(const char *string1, Compares two strings using the
const char *string2); collating sequence in the current
locale.
strcpy string.h char *strcpy(char *string1, const Copies string2 into string1.
char *string2);
strcspn string.h size_t strcspn(const char Returns the length of the initial
*string1, const char *string2); substring of string1 consisting of
characters not contained in
string2.
strfmon4 wchar.h int strfmon (char *s, size_t Converts monetary value to
maxsize, const char *format, ...); string.
strftime time.h size_t strftime (char *dest, size_t Stores characters in an array
maxsize, const char *format, pointed to by dest, according to
const struct tm *timeptr); the string determined by format.
strlen string.h size_t strlen(const char *string); Calculates the length of string.
strptime4 time.h char *strptime (const char *buf, Date and time conversion
const char *format, struct tm
*tm);
strrchr string.h char *strrchr(const char *string, Locates the last occurrence of c in
int c); string.
strspn string.h size_t strspn(const char *string1, Returns the length of the initial
const char *string2); substring of string1 consisting of
characters contained in string2.
strstr string.h char *strstr(const char *string1, Returns a pointer to the first
const char *string2); occurrence of string2 in string1.
strtof stdlib.h float strtof(const char *nptr, Converts nptr to a float value.
char **endptr);
strtok string.h char *strtok(char *string1, const Locates the next token in string1
char *string2); delimited by the next character in
string2.
strtok_r string.h char *strtok_r(char *string, const Locates the next token in string
char *seps, char **lasts); delimited by the next character in
seps. (Restartable version of
System
Function Include File Function Prototype Description
strtok.)
strtol stdlib.h long int strtol(const char *nptr, Converts nptr to a signed long
char **endptr, int base); integer.
strtold stdlib.h long double strtold(const char Converts nptr to a long double
*nptr, char **endptr); value.
strxfrm string.h size_t strxfrm(char *string1, Converts string2 and places the
const char *string2, size_t result in string1. The conversion
count); is determined by the program's
current locale.
swscanf wchar.h int swscanf (const wchar_t Reads data from buffer into the
*buffer, const wchar_t *format, locations given by arg-list.
arg-list)
system stdlib.h int system(const char *string); Passes string to the system
command analyzer.
ungetc1 stdio.h int ungetc(int c, FILE *stream); Pushes c back onto the input
stream.
ungetwc6 stdio.h wint_t ungetwc(wint_t wc, FILE Pushes the wide character wc
wchar.h *stream); back onto the input stream.
va_copy stdarg.h void va_copy(va_list dest, va_list Initializes dest as a copy of src.
src);
vfprintf stdio.h int vfprintf(FILE *stream, const Formats and prints characters to
stdarg.h char *format, va_list arg_ptr); the output stream using a
variable number of arguments.
vfscanf stdio.h int vfscanf(FILE *stream, const Reads data from a specified
stdarg.h char *format, va_list arg_ptr); stream into locations given by a
variable number of arguments.
vfwscanf stdio.h int vfwscanf(FILE *stream, const Reads wide data from a specified
stdarg.h wchar_t *format, va_list stream into locations given by a
arg_ptr); variable number of arguments.
vprintf stdio.h int vprintf(const char *format, Formats and prints characters to
stdarg.h va_list arg_ptr); stdout using a variable number of
arguments.
vscanf stdio.h int vscanf(const char *format, Reads data from stdin into
stdarg.h va_list arg_ptr); locations given by a variable
number of arguments.
vsnprintf stdio.h int vsnprintf(char *outbuf, size_t Same as vsprintf except that the
n, const char*, va_list); function will stop after n
characters have been written to
outbuf.
vsscanf stdio.h int vsscanf(const char*buffer, Reads data from a buffer into
stdarg.h const char *format, va_list locations given by a variable
arg_ptr); number of arguments.
vswscanf stdio.h int vswscanf(const wchar_t Reads wide data from a buffer
wchar.h *buffer, const wchar_t *format, into locations given by a variable
va_list arg_ptr); number of arguments.
vwscanf stdio.h int vwscanf(const wchar_t Reads wide data from stdin into
wchar.h *format, va_list arg_ptr); locations given by a variable
number of arguments.
wcrtomb4 wchar.h int wcrtomb (char *s, wchar_t Converts a wide character to a
wchar, mbstate_t *pss); multibyte character. (Restartable
version of wctomb.)
System
Function Include File Function Prototype Description
wcsftime wchar.h size_t wcsftime(wchar_t *wdest, Converts the time and date
size_t maxsize, const wchar_t specification in the timeptr
*format, const struct tm structure into a wide-character
*timeptr); string.
result.
wcsrtombs4 wchar.h size_t wcsrtombs (char *dst, Converts wide character string to
const wchar_t **src, size_t len, multibyte string. (Restartable
mbstate_t *ps); version of wcstombs.)
wcstod wchar.h double wcstod(const wchar_t Converts the initial portion of the
*nptr, wchar_t **endptr); wide-character string pointed to
by nptr to a double value.
wcstof wchar.h float wcstof(const wchar_t Converts the initial portion of the
*nptr, wchar_t **endptr); wide-character string pointed to
by nptr to a float value.
wcstol wchar.h long int wcstol(const wchar_t Converts the initial portion of the
*nptr, wchar_t **endptr, int wide-character string pointed to
base); by nptr to a long integer value.
wcstold wchar.h long double wcstold(const Converts the initial portion of the
wchar_t *nptr, wchar_t wide-character string pointed to
**endptr); by nptr to a long double value.
wcstombs stdlib.h size_t wcstombs(char *dest, Converts the wchar_t string into
const wchar_t *string, size_t a multibyte string dest.
count);
wcstoul wchar.h unsigned long int wcstoul(const Converts the initial portion of the
wchar_t *nptr, wchar_t wide-character string pointed to
**endptr, int base); by nptr to an unsigned long
integer value.
wctype4 wchar.h wctype_t wctype (const char Obtains handle for character
*property); property classification.
wmemset wchar.h wchar_t *wmemset(wchar_t *s, Copies the value of c into each of
wchar_t c, size_t n); the first n wide characters of the
object pointed to by s.