load
load
load
load
load
load
load
load
Sugarcane will be shutting down on June 30, 2018. For more information, .

The C Library Reference Guide

Notes based on the "The C Library Reference Guide", by Eric Huss: - https://www-s.acm.illinois.edu/webmonkeys/book/c_guide/
a data set by igal
created December 4, 2016
COPY & EDIT
FAMILY TREE
Play a game to test your knowledge!
See all 10 games!
See fewer games
Function NameFunction PrototypeReturn ValueParameter NamesParameter TypesHeader FileFunction DescriptionFunction TypeMnemonic
abortvoid abort(void)voidnonevoidstdlib.hCauses an abnormal program termination.Regular Function
absint abs(int x)intxintstdlib.hReturns the absolute value of an int.Regular Function
acosdouble acos(double x)doublexdoublemath.hReturns the arc cosine (in radians) of a double.Regular Functionnone
asctimechar *asctime(const struct tm *timeptr)char *timeptrconst struct tm *time.hConverts a time structure to a string.Regular FunctionAscii Time
asindouble asin(double x)doublexdoublemath.hReturns the arc sine (in radians) of a double.Regular Functionnone
assertvoid assert(int expression)voidexpressionintassert.hAllows diagnostic information to be written to the standard error file.Macro Function
atandouble atan(double x)doublexdoublemath.hReturns the arc tangent (in radians) of a double.Regular Functionnone
atan2double atan2(double y, double x)doubley, xdouble, doublemath.hReturns the arc tangent (in radians) of a pair of doubles.Regular FunctionArc Tangent with 2 Arguments
atexitint atexit(void (*func)(void))intfuncvoid (*)(void)stdlib.hCauses the specified function to be called when the program terminates normally.Regular Function
atofdouble atof(const char *str)doublestrconst char *stdlib.hConverts a string to a double.Regular FunctionAscii-to-Float
atoiint atoi(const char *str)intstrconst char *stdlib.hConverts a string to an integer.Regular FunctionAscii-to-Int
atollong int atol(const char *str)long intstrconst char *stdlib.hConverts a string to a long int.Regular FunctionAscii-to-Long
bsearchvoid *bsearch(const void *key, const void *base, size_t nitems, size_t size, int (*compar)(const void *, const void *))void *key, base, nitems, size, comparconst void *, const void *, size_t, size_t, int (*)(const void *, const void *)stdlib.hPerforms a binary search on a sorted table.Regular FunctionBinary Search
callocvoid *calloc(size_t nitems, size_t size)void *nitems, sizesize_t, size_tstdlib.hAllocates and initializes the requested memory and returns a pointer to it.Regular FunctionClear Allocate
ceildouble ceil(double x)doublexdoublemath.hReturns the smallest integer value greater than or equal to x.Regular FunctionCeiling
clearerrvoid clearerr(FILE *stream)voidstreamFILE *stdio.hClears the end-of-file and error indicators for the given stream.Regular FunctionClear Error
clockclock_t clock(void)clock_tnonevoidtime.hReturns the processor clock time since the beginning of the program.Regular Function
cosdouble cos(double x)doublexdoublemath.hReturns the cosine of a radian angle x.Regular Functionnone
coshdouble cosh(double x)doublexdoublemath.hReturns the hyperbolic cosine of x.Regular Functionnone
ctimechar * ctime(const time_t *timer)char *timerconst time_t *time.hConverts a time_t value to a string based on the local time zone.Regular FunctionConvert Time
difftimedouble difftime(time_t time1, time_t time2);doubletime1, time2time_t, time_ttime.hCalculates the difference in seconds between two times.Regular FunctionDifference in Time
divdiv_t div(int numer, int denom)div_tnumer, denomint, intstdlib.hPerforms Euclidean division of two integers and returns a struct containing the quotient and remainder.Regular FunctionDivision
exitvoid exit(int status)voidstatusintstdlib.hCauses the program to terminate normally.Regular Function
expdouble exp(double x)doublexdoublemath.hReturns the value of e raised to the xth power.Regular Function
fabsdouble fabs(double x)doublexdoublemath.hReturns the absolute value of a floating-point number.Regular Function
fcloseint fclose(FILE *stream)intstreamFILE *stdio.hCloses the given file stream and flushes all buffers.Regular FunctionFile Close
feofint feof(FILE *stream)intstreamFILE *stdio.hTests the end-of-file indicator for the given stream.Regular FunctionEnd of File
ferrorint ferror(FILE *stream)intstreamFILE *stdio.hTests the error indicator for the given stream.Regular FunctionFile Error
fflushint fflush(FILE *stream)intstreamFILE *stdio.hFlushes the output buffer of the given stream.Regular FunctionFile Flush
fgetcint fgetc(FILE *stream)intstreamFILE *stdio.hGets the next character (an unsigned char) from the specified stream and advances the position indicator for the stream.Regular FunctionFile Get Char
fgetposint fgetpos(FILE *stream, fpos_t *pos)intstream, posFILE *, fpos_tstdio.hGets the current file position of the given stream and writes it to an fpos_t.Regular FunctionFile Get Position
fgetschar *fgets(char *str, int n, FILE *stream)char *str, n, streamchar *, int, FILE *stdio.hReads a line from the specified stream and stores it into the string pointed to by str.Regular FunctionFile Get String
floordouble floor(double x)doublexdoublemath.hReturns the largest integer value less than or equal to x.Regular Function
fmoddouble fmod(double x, double y)doublex, ydouble, doublemath.hPerforms Euclidean division on two floating point numbers and returns the remainder.Regular Function
fopenFILE *fopen(const char *filename, const char *mode)FILE *filename, modeconst char *, const char *stdio.hOpens the file pointed to by the given filename.Regular FunctionFile Open
fprintfint fprintf(FILE *stream, const char *format, ...)intstream, format, ...FILE *, const char *, ...stdio.hSends formatted output to a stream.Regular FunctionFile Print Formatted
fputcint fputc(int char, FILE *stream)intchar, streamint, FILE *stdio.hWrites a character (an unsigned char) specified by the argument char to the specified stream and advances the position indicator for the stream.Regular FunctionFile Put Char
fputsint fputs(const char *str, FILE *stream)intstr, streamconst char *, FILE *stdio.hWrites a string to the specified stream up to but not including the null character.Regular FunctionFile Put String
freadsize_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)size_tptr, size, nmemb, streamvoid *, size_t, size_t, FILE *stdio.hReads data from a stream and writes it to an array.Regular FunctionFile Read
freevoid free(void *ptr)voidptrvoid *stdlib.hDeallocates memory previously allocated by a call to calloc, malloc, or realloc.Regular Function
freopenFILE *freopen(const char *filename, const char *mode, FILE *stream)FILE *filename, mode, streamconst char *, const char *, FILE *stdio.hAssociates a new filename with the given open stream.Regular FunctionFile Reopen
frexpdouble frexp(double x, int *exponent)doublex, exponentdouble, int *math.hReturns the mantissa of x and points exponent to the exponent of x.Regular Function
fscanfint fscanf(FILE *stream, const char *format, ...)intstream, format, ...FILE *, const char *, ...stdio.hReads formatted input from a stream.Regular FunctionFile Scan Formatted
fseekint fseek(FILE *stream, long int offset, int whence)intstream, offset, whenceFILE *, long int, intstdio.hSets the file position of the stream to an offset represented by a long int.Regular FunctionFile Seek
fsetposint fsetpos(FILE *stream, const fpos_t *pos)intstream, posFILE *, const fpos_t *stdio.hSets the file position of a stream to the position represented by a fpos_t.Regular FunctionFile Set Position
ftelllong int ftell(FILE *stream)long intstreamFILE *stdio.hReturns the current file position of a stream as a long int.Regular FunctionFile Tell?
fwritesize_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)size_tptr, size, nmemb, streamconst void *, size_t, size_t, FILE *stdio.hWrites data from an array to a stream.Regular FunctionFile Write
getcint getc(FILE *stream)intstreamFILE *stdio.hA macro function that gets the next character (an unsigned char) from the specified stream and advances the position indicator for the stream.Macro FunctionGet Char
getcharint getchar(void)intnonevoidstdio.hGets a character (an unsigned char) from stdin.Regular Function
getenvchar *getenv(const char *name)char *nameconst char *stdlib.hReturns the value of an environment variable.Regular FunctionGet Environment Variable
getschar *gets(char *str)char *strchar *stdio.hReads a line from stdin and stores it into the string pointed to by str.Regular FunctionGet String
gmtimestruct tm *gmtime(const time_t *timer)struct tm *timerconst time_t *time.hTakes a time object and returns the Greenwich Mean Time.Regular FunctionGreenwich Mean Time
isalnumint isalnum(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is a letter or a digit.Regular FunctionIs Alpha-Numeric
isalphaint isalpha(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is a letter.Regular FunctionIs Alphabetic
iscntrlint iscntrl(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is a control character.Regular FunctionIs Control
isdigitint isdigit(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is a digit.Regular FunctionIs Digit
isgraphint isgraph(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is a visible printing character.Regular FunctionIs Graphical
islowerint islower(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is a lowercase letter.Regular FunctionIs Lowercase
isprintint isprint(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is a printing character.Regular FunctionIs Printable
ispunctint ispunct(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is a punctuation character.Regular FunctionIs Punctuation
isspaceint isspace(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is a whitespace character.Regular FunctionIs Space
isupperint isupper(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is an upper case character.Regular FunctionIs Uppercase
isxdigitint isxdigit(int character)intcharacterintctype.hTests the given character and returns a nonzero (true) result if it is a hexadecimal digit.Regular FunctionIs heXadecimal Digit
labslong int labs(long int x)long intxlong intstdlib.hReturns the absolute value of a long int.Regular FunctionLong Absolute Value
ldexpdouble ldexp(double x, int exponent)doublex, exponentdouble, intmath.hReturns x multiplied by 2 raised to the power of exponent.Regular Function
ldivldiv_t ldiv(long int numer, long int denom)ldiv_tnumer, denomlong int, long intstdlib.hPerforms Euclidean division of two long integers and returns a struct containing the quotient and remainder.Long Division
localeconvstruct lconv *localeconv(void)struct lconvnonevoidlocale.hSets the structure lconv to represent the current location settings.Regular FunctionLocale Conversion
localtimestruct tm *localtime(const time_t *timer)struct tm *timerconst time_t *time.hConverts a time_t value to a time structure based on the local time zone.Regular Function
logdouble log(double x)doublexdoublemath.hReturns the natural logarithm (base-e logarithm) of x.Regular Function
log10double log10(double x)doublexdoublemath.hReturns the common logarithm (base-10 logarithm) of x.Regular Function
longjmpvoid longjmp(jmp_buf environment, int value)voidenvironment, valuejmp_buf, intsetjmp.hCauses the environment to be restored from a setjmp call where the environment variable had been saved.Regular FunctionLong Jump
mallocvoid *malloc(size_t size)void *sizesize_tstdlib.hAllocates (but does not initialize) the requested memory and returns a pointer to it.Regular FunctionMemory Allocate
mblenint mblen(const char *str, size_t n)intstr, nconst char *, size_tstdlib.hReturns the length of a multibyte character.Regular FunctionMulti-Byte Length
mbstowcssize_t mbstowcs(wchar_t *pwcs, const char *str, size_t n)size_tpwcs, str, nwchar_t *, const char *, size_tstdlib.hConvert a multibyte string to a wide-character string.Regular FunctionMulti-Byte String to Wide-Character String
mbtowcint mbtowc(whcar_t *pwc, const char *str, size_t n)intpwc, str, nwchar_t *, const char *, size_tstdlib.hConverts a multibyte sequence to a wide character.Regular FunctionMulti-Byte to Wide-Character
memchrvoid *memchr(const void *str, int c, size_t n);void *str, c, nconst void *, int, size_tstring.hSearches for the occurrence of a character in a string and returns a pointer to the first match.Regular FunctionMemory Character
memcmpint memcmp(const void *str1, const void *str2, size_t n);intstr1, str2, nconst void *, const void *, size_tstring.hCompares two strings byte by byte and returns an int indicating which is greater.Regular FunctionMemory Compare
memcpyvoid *memcpy(void *str1, const void *str2, size_t n);void *str1, str2, nvoid *, const void *, size_tstring.hCopies characters from one string to another provided that the two strings are disjoint.Regular FunctionMemory Copy
memmovevoid *memmove(void *str1, const void *str2, size_t n);void *str1, str2, nvoid *, const void *, size_tstring.hCopies characters from one string to another even if the two strings overlap.Memory Move
memsetvoid *memset(void *str, int c, size_t n);void *str, c, nvoid *, int, size_tstring.hOverwrites the beginning of a string by some number of repetitions of a given character.Regular FunctionMemory Set
mktimetime_t mktime(struct tm *timeptr)time_ttimeptrstruct tm *time.hConverts a time structure to a time_t value.Regular FunctionMake Time
modfdouble modf(double x, double *integer)doublex, integerdouble, double *math.hBreaks the floating-point number x into integer and fraction components.Regular Function
offsetofoffsetof(type, member)size_ttype, membermacro, macrostddef.hComputes the offset in bytes of a structure member from the beginning of the structure.Macro Function
perrorvoid perror(const char *str)voidstrconst char *stdio.hPrints a descriptive error message to stderr.Regular FunctionPrint Error
powdouble pow(double x, double y)doublex, ydouble, doublemath.hReturns x raised to the power of y.Regular Function
printfint printf(const char *format, ...)intformat, ...const char *, ...stdio.hSends formatted output to stdout.Regular FunctionPrint Formatted
putcint putc(int char, FILE *stream)intchar, streamint, FILE *stdio.hMacro function that writes a character (an unsigned char) specified by the argument char to the specified stream and advances the position indicator for the stream.Macro FunctionPut Char
putcharint putchar(int char)intcharintstdio.hWrites a character (an unsigned char) to stdout.Regular Function
putsint puts(const char *str)intstrconst char *stdio.hWrites a string to stdout up to but not including the null character and appends a newline character to the output.Regular FunctionPut String
qsortvoid qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*));voidbase, nitems, size, comparvoid *, size_t, size_t, int (*)(const void *, const void *)stdlib.hSorts an array using the quicksort algorithm.Regular FunctionQuick-Sort
raiseint raise(int sig)intsigintsignal.hCauses signal sig to be generated.Regular Function
randint rand(void)intnonevoidstdlib.hReturns a pseudo-random number in the range of 0 to RAND_MAX.Regular FunctionRandom Number
reallocvoid *realloc(void *ptr, size_t size)void *ptr, sizevoid *, size_tstdlib.hAttempts to resize a memory block that was previously allocated with a call to malloc or calloc.Regular FunctionRe-Allocate
removeint remove(const char *filename)intfilenameconst char *stdio.hDeletes the given filename so that it is no longer accessible (unlinks the file).Regular Function
renameint rename(const char *old_filename, const char *new_filename)intold_filename, new_filenameconst char *, const char *stdio.hRenames a file.Regular Function
rewindvoid rewind(FILE *stream)voidstreamFILE *stdio.hSets the file position to the beginning of the file of the given stream and resets the error and end-of-file indicators.Regular Function
scanfint scanf(const char *format, ...)intformat, ...const char *, ...stdio.hReads formatted input from stdin.Regular FunctionScan Formatted
setbufvoid setbuf(FILE *stream, char *buffer)voidstream, bufferFILE *, char *stdio.hSpecifies that the given stream should be buffered to the given array of the default size.Regular FunctionSet Buffer
setjmpint setjmp(jmp_buf environment)intenvironmentjmp_bufsetjmp.hSaves the environment into the variable environment.Macro FunctionSet Jump
setlocalechar *setlocale(int category, const char *locale)charcategory, localeint, const char *locale.hSets or reads location dependent information.Regular Function
setvbufint setvbuf(FILE *stream, char *buffer, int mode, size_t size)intstream, buffer, mode, sizeFILE *, char *, int, size_tstdio.hSpecifies that the given stream should be buffered to the given array of the specified size.Regular FunctionSet Variable-Size Buffer
signalvoid (*signal(int sig, void (*func)(int)))(int)void (*)(int)sig, funcint, void (*)(int)signal.hControls how a signal is handled.Regular Function
sindouble sin(double x)doublexdoublemath.hReturns the sine of a radian angle x.Regular Function
sinhdouble sinh(double x)doublexdoublemath.hReturns the hyperbolic sine of x.Regular Function
sprintfint sprintf(char *str, const char *format, ...)intstr, format, ...char *, const char *, ...stdio.hSends formatted output to a string.Regular FunctionString Print Formatted
sqrtdouble sqrt(double x)doublexdoublemath.hReturns the square root of x.Regular Function
srandvoid srand(unsigned int seed)voidseedunsigned intstdlib.hSeeds the random number generator used by the function rand.Regular FunctionSeed Random
sscanfint sscanf(const char *str, const char *format, ...)intstr, format, ...const char *, const char *, ...stdio.hReads formatted input from a string.Regular FunctionString Scan Formatted
strcatchar *strcat(char *str1, const char *str2);char *str1, str2char *, const char *string.hAppends one string to the end of another.Regular FunctionString Concatenation
strchrchar *strchr(const char *str, int c);char *str, cconst char *, intstring.hSearches for the first occurrence of a character in a null-terminated string.Regular FunctionString Character
strcmpint strcmp(const char *str1, const char *str2);intstr1, str2const char *, const char *string.hCompares two null-terminated strings byte by byte and returns an int indicating which is greater.Regular FunctionString Compare
strcollint strcoll(const char *str1, const char *str2);intstr1, str2const char *, const char *string.hCompares two strings using LC_COLLATE.Regular FunctionString Collate
strcpychar *strcpy(char *str1, const char *str2);char *str1, str2char *, const char *string.hCopies one null-terminated string to another.Regular FunctionString Copy
strcspnsize_t strcspn(const char *str1, const char *str2);size_tstr1, str2const char *, const char *string.hDetermines the initial span of characters in a first string that are not contained in a second string and returns the number of characters spanned.Regular FunctionString Complement Span
strerrorchar *strerror(int errnum)char *errnumintstring.hSearches an internal array for an error number and returns a pointer to the corresponding error message string.Regular FunctionString Error
strftimesize_t strftime(char *str, size_t maxsize, const char *format, const struct tm *timeptr);size_tstr, maxsize, format, timeptrchar *, size_t, const char *, const struct tm *time.hConverts a time to a string according to a given format.Regular FunctionString Format Time
strlensize_t strlen(const char *str)size_tstrconst char *string.hComputes the length of a string up to but not including the terminating null character.Regular FunctionString Length
strncatchar *strncat(char *str1, const char *str2, size_t n);char *str1, str2, nchar *, const char *, size_tstring.hAppends a substring of one string to the end of another.Regular FunctionString of Length n Concatentation
strncmpint strncmp(const char *str1, const char *str2, size_t n);intstr1, str2, nconst char *, const char *, size_tstring.hCompares two null-terminated strings up until a given index.Regular FunctionString Length n Compare
strncpychar *strncpy(char *str1, const char *str2, size_t n);char *str1, str2, nchar *, const char *, size_tstring.hCopies a substring of one null-terminated string to another.Regular FunctionString Length n Copy
strpbrkchar * strpbrk(const char *str1, const char *str2);char *str1, str2const char *, const char *string.hFinds the first character in a first string that matches any character specified in a second string and returns a pointer to the matching character.Regular FunctionString Pointer Break
strrchrchar *strrchr(const char *str, int c);char *str, cconst char *, intstring.hSearches for the last occurrence of a character in a string.Regular FunctionString Rightmost Character
strspnsize_t strspn(const char *str1, const char *str2);size_tstr1, str2const char *, const char *string.hDetermines the initial span of characters in a first string that are also contained in a second string and returns the number of characters spanned.Regular FunctionString Span
strstrchar *strstr(const char *str1, const char *str2);char *str1, str2const char *, const char *string.hFinds the first occurrence of one string as a substring of another.Regular FunctionString in String
strtoddouble strtod(const char *str, char **endptr)doublestr, endptrconst char *, char **stdlib.hConverts the initial part of a string to a double.Regular FunctionString-to-Double
strtokchar *strtok(char *str1, const char *str2);char *str1, str2char *, const char *string.hBreaks a string into a sequence of tokens based on a separator.Regular FunctionString to Tokens
strtollong int strtol(const char *str, char **endptr, int base)long intstr, endptr, baseconst char *, char **, intstdlib.hConverts the initial part of a string to a long int.Regular FunctionString-to-Long
strtoulunsigned long int strtoul(const char *str, char **endptr, int base)unsigned long intstr, endptr, baseconst char *, char **, intstdlib.hConverts the initial part of a string to an unsigned long int.Regular FunctionString to Unsigned Long
strxfrmsize_t strxfrm(char *str1, const char *str2, size_t n);size_tstr1, str2, nchar *, const char *, size_tstring.hTransforms a string using the current locale settings.Regular FunctionString Transform
systemint system(const char *string)intstringconst char *stdlib.hPasses a string to the host environment to be executed by the command processor.Regular FunctionSystem Call
tandouble tan(double x)doublexdoublemath.hReturns the tangent of a radian angle x.Regular Function
tanhdouble tanh(double x)doublexdoublemath.hReturns the hyperbolic tangent of x.Regular Function
timetime_t time(time_t *timer)time_ttimertime_t *time.hCalculates the current calender time and encodes it into time_t format.Regular Function
tmpfileFILE *tmpfile(void)FILE *nonevoidstdio.hCreates a temporary file in binary update mode.Regular FunctionTemporary File
tmpnamchar *tmpnam(char *str)char*strchar *stdio.hGenerates and returns a valid temporary filename which does not exist.Regular FunctionTemporary Name
tolowerint tolower(int character)intcharacterintctype.hConverts a character to lower case.Regular FunctionTo Lowercase
toupperint toupper(int character)intcharacterintctype.hConverts a character to upper case.Regular FunctionTo Uppercase
ungetcint ungetc(int char, FILE *stream)intchar, streamint, FILE *stdio.hPushes the character char (an unsigned char) onto the specified stream so that the this is the next character read.Regular FunctionUnget Char
va_argtype va_arg(va_list ap, type)macroap, typeva_list, macrostdarg.hExpands to the next argument in a paramater list of a function with type type.Macro FunctionVariable Arguments
va_endtype va_arg(va_list ap, type)macroap, typeva_list, macrostdarg.hAllows a function with variable arguments which used the va_start macro to return.Macro FunctionEnd Variable Arguments
va_startvoid va_start(va_list ap, last_arg)voidap, last_argva_list, macrostdarg.hInitializes a va_list for use with the va_arg and va_end macros.Macro FunctionStart Variable Arguments
vfprintfint vfprintf(FILE *stream, const char *format, va_list argintstream, format, argFILE *, const char *, va_liststdio.hSends formatted output to a stream using an argument list.Regular FunctionVariable File Print Formatted
vprintfint vprintf(const char *format, va_list arg)intformat, argconst char *, va_liststdio.hSends formatted output to stdout using an argument list.Regular FunctionVariable Print Formatted
vsprintfint vsprintf(char *str, const char *format, va_list arg)intstr, format, argchar *, const char *, va_liststdio.hSends formatted output to a string using an argument list.Regular FunctionVariable String Print Formatted
wcstombssize_t wcstombs(char *str, const wchar_t *pwcs, size_t n)size_tstr, pwcs, nchar *, const wchar_t *, size_tstdlib.hConverts a wide-character string to a multibyte string.Regular FunctionWide-Character String to Multi-Byte String
wctombint wctomb(char *str, wchar_t wchar)intstr, wcharchar *, wchar_tstdlib.hConverts a wide character to a multibyte sequence.Regular FunctionWide-Character to Multi-Byte
Ready to learn about The C Library Reference Guide?