[Last modified : 2003.07.09]
<assert.h> : Diagnostics<ctype.h> : Character Class Tests<errno.h> : Error Codes Reported by (Some) Library Functions<float.h> : Implementation-defined Floating-Point Limits<limits.h> : Implementation-defined Limits<locale.h> : Locale-specific Information<math.h> : Mathematical Functions<setjmp.h> : Non-local Jumps<signal.h> : Signals<stdarg.h> : Variable Argument Lists<stddef.h> : Definitions of General Use<stdio.h> : Input and Output<stdlib.h> : Utility functions<string.h> : String functions<time.h> : Time and Date functionsvoid assert(int expression);NDEBUG is defined where <assert.h>
is included.) If expression equals zero, message printed on
stderr and abort
called to terminate execution. Source filename and line number in message are
from preprocessor macros __FILE__ and __LINE__.[Contents]
int isalnum(int c);isalpha(c) or isdigit(c)int isalpha(int c);isupper(c) or islower(c)int iscntrl(int c);0x00 (NUL) to 0x1F (US), and 0x7F (DEL)int isdigit(int c);int isgraph(int c);int islower(int c);int isprint(int c);0x20 (' ') to 0x7E ('~')int ispunct(int c);int isspace(int c);int isupper(int c);int isxdigit(int c);int tolower(int c);int toupper(int c);[Contents]
errnoEDOMERANGENotes:
[Contents]
FLT_RADIXFLT_ROUNDSWhere the prefix "FLT" pertains to type float, "DBL" to type double, and "LDBL" to type long double:
FLT_DIGDBL_DIGLDBL_DIGFLT_EPSILONDBL_EPSILONLDBL_EPSILON1.0 + x != 1.0FLT_MANT_DIGDBL_MANT_DIGLDBL_MANT_DIGFLT_RADIX, in mantissaFLT_MAXDBL_MAXLDBL_MAXFLT_MAX_EXPDBL_MAX_EXPLDBL_MAX_EXPFLT_RADIX can be raised and remain representableFLT_MINDBL_MINLDBL_MINFLT_MIN_EXPDBL_MIN_EXPLDBL_MIN_EXPFLT_RADIX can be raised and remain representable[Contents]
CHAR_BITcharCHAR_MAXcharCHAR_MINcharSCHAR_MAXsigned charSCHAR_MINsigned charUCHAR_MAXunsigned charSHRT_MAXshortSHRT_MINshortUSHRT_MAXunsigned shortINT_MAXintINT_MINintUINT_MAXunsigned intLONG_MAXlongLONG_MINlongULONG_MAXunsigned long[Contents]
struct lconvchar* decimal_point;char* grouping;char* thousands_sep;char* currency_symbol;char* int_curr_symbol;char* mon_decimal_point;char* mon_grouping;char* mon_thousands_sep;char* negative_sign;char* positive_sign;char frac_digits;char int_frac_digits;char n_cs_precedes;1) or follows (0) negative monetary valueschar n_sep_by_space;1) or is not (0) separated by space from negative monetary valueschar n_sign_posn;01234char p_cs_precedes;1) or follows (0) positive monetary valueschar p_sep_by_space;1) or is not (0) separated by space from non-negative monetary valueschar p_sign_posn;n_sign_posndecimal_point.struct lconv* localeconv(void);char* setlocale(int category, const char* locale);category and locale. Returns string describing new locale or null on error. (Implementations are permitted to define values of category additional to those describe here.)LC_ALLcategory argument for all categoriesLC_NUMERICcategory for numeric formatting informationLC_MONETARYcategory for monetary formatting informationLC_COLLATEcategory for information affecting collating functionsLC_CTYPEcategory for information affecting character class tests functionsLC_TIMEcategory for information affecting time conversions functionsNULL[Contents]
On domain error, implementation-defined value returned and errno set to EDOM. On range error, errno set to ERANGE and return value is HUGE_VAL with correct sign for overflow, or zero for underflow. Angles are in radians.
HUGE_VALdouble exp(double x);xdouble log(double x);xdouble log10(double x);xdouble pow(double x, double y);x raised to power ydouble sqrt(double x);xdouble ceil(double x);xdouble floor(double x);xdouble fabs(double x);xdouble ldexp(double x, int n);x times 2 to the power ndouble frexp(double x, int* exp);x non-zero, returns value, with absolute value in interval [1/2, 1), and assigns to *exp integer such that product of return value and 2 raised to the power *exp equals x; if x zero, both return value and *exp are zerodouble modf(double x, double* ip);*ip integral part of x, both with same sign as xdouble fmod(double x, double y);y non-zero, floating-point remainder of x/y, with same sign as x; if y zero, result is implementation-defineddouble sin(double x);xdouble cos(double x);xdouble tan(double x);xdouble asin(double x);xdouble acos(double x);xdouble atan(double x);xdouble atan2(double y, double x);y/xdouble sinh(double x);xdouble cosh(double x);xdouble tanh(double x);x[Contents]
jmp_bufint setjmp(jmp_buf env);env and returns zero. Subsequent call to longjmp with same env returns non-zero.void longjmp(jmp_buf env, int val);setjmp with specified env. Execution resumes as a second return from setjmp, with returned value val if specified value non-zero, or 1 otherwise.[Contents]
SIGABRTSIGFPESIGILLSIGINTSIGSEGVSIGTERMSIG_DFLSIG_ERRsignal return value indicating errorSIG_IGNvoid (*signal(int sig, void (*handler)(int)))(int);handler is SIG_DFL, implementation-defined default behaviour will be used; if SIG_IGN, signal will be ignored; otherwise function pointed to by handler will be invoked with argument sig. In the last case, handling is restored to default behaviour before handler is called. If handler returns, execution resumes where signal occurred. signal returns the previous handler or SIG_ERR on error. Initial state is implementation-defined. Implementations may may define signals additional to those listed here.int raise(int sig);sig. Returns zero on success.[Contents]
va_listvoid va_start(va_list ap, lastarg);ap. lastarg is the last named parameter of the function.type va_arg(va_list ap, type);type) and value of the next unnamed argument.void va_end(va_list ap);[Contents]
NULLoffsetof(stype, m)m from start of structure type stype.ptrdiff_tsize_tsizeof operator.[Contents]
BUFSIZsetbuf.EOFFILENAME_MAXFOPEN_MAXL_tmpnamtmpnam.NULLSEEK_CURorigin argument to fseek specifying current file position.SEEK_ENDorigin argument to fseek specifying end of file.SEEK_SETorigin argument to fseek specifying beginning of file.TMP_MAXtmpnam._IOFBFmode argument to setvbuf specifying full buffering._IOFBFmode argument to setvbuf specifying line buffering._IOFBFmode argument to setvbuf specifying no buffering.stdinstdoutstderrFILEfpos_tsize_tsizeof operator.FILE* fopen(const char* filename, const char* mode);filename and returns a stream, or NULL on failure. mode may be one of the following for text files:"r""w""a""r+""w+""a+"b included (after the first character), for binary files.FILE* freopen(const char* filename, const char* mode, FILE* stream);stream, then opens file filename with specified mode and associates it with stream. Returns stream or NULL on error.int fflush(FILE* stream);stream and returns zero on success or EOF on error. Effect undefined for input stream. fflush(NULL) flushes all output streams.int fclose(FILE* stream);EOF on error, zero otherwise.int remove(const char* filename);int rename(const char* oldname, const char* newname);oldname to newname. Returns non-zero on failure.FILE* tmpfile();"wb+") which will be removed when closed or on normal program termination. Returns stream or NULL on failure.char* tmpname(char s[L_tmpnam]);s (if s non-null) and returns unique name for a temporary file. Unique name is returned for each of the first TMP_MAX invocations.int setvbuf(FILE* stream, char* buf, int mode, size_t size);stream. mode is _IOFBF for full buffering, _IOLBF for line buffering, _IONBF for no buffering. Non-null buf specifies buffer of size size to be used; otherwise, a buffer is allocated. Returns non-zero on error. Call must be before any other operation on stream.void setbuf(FILE* stream, char* buf);buf, turns off buffering, otherwise equivalent to (void)setvbuf(stream,buf,_IOFBF,BUFSIZ).int fprintf(FILE* stream, const char* format, ...);format) and writes output to stream stream. Number of characters written, or negative value on error, is returned. Conversion specifications consist of:%-+0#o, first digit will be zero, for [xX], prefix 0x or 0X to non-zero value, for [eEfgG], always decimal point, for [gG]
trailing zeros not removed.*, value taken from next argument (which must be int).. (separating width from precision):s, maximum characters to be printed from the string, for [eEf], digits after decimal point, for [gG], significant digits, for an integer, minimum number of digits to be printed. If specified as *, value taken from next argument (which must be int).hshort or unsigned shortllong or unsigned longLlong doubled,iint argument, printed in signed decimal notationoint argument, printed in unsigned octal notationx,Xint argument, printed in unsigned hexadecimal notationuint argument, printed in unsigned decimal notationcint argument, printed as single characterschar* argumentfdouble argument, printed with format [-]mmm.ddde,Edouble argument, printed with format [-]m.dddddd(e|E)(+|-)xxg,Gdouble argumentpvoid* argument, printed as pointernint* argument : the number of characters written to this point is written into argument%int printf(const char* format, ...);printf(f, ...) is equivalent to
fprintf(stdout, f, ...)int sprintf(char* s, const char* format, ...);s, which must be large enough to hold the output, rather than to a stream. Output is NUL-terminated. Returns length (excluding the terminating NUL).int vfprintf(FILE* stream, const char* format, va_list arg);fprintf with variable argument list replaced by arg, which must have been initialised by the va_start macro (and may have been used in calls to va_arg).int vprintf(const char* format, va_list arg);printf with variable argument list replaced by arg, which must have been initialised by the va_start macro (and may have been used in calls to va_arg).int vsprintf(char* s, const char* format, va_list arg);sprintf with variable argument list replaced by arg, which must have been initialised by the va_start macro (and may have been used in calls to va_arg).int fscanf(FILE* stream, const char* format, ...);stream according to format format. The function returns when format is fully processed. Returns number of items converted and assigned, or EOF if end-of-file or error occurs before any conversion. Each of the arguments following format must be a pointer. Format string may contain:%*"hshort rather than intllong rather than int, or double rather than floatLlong double rather than floatdint* parameter requirediint* parameter required; decimal, octal or hexoint* parameter requireduunsigned int* parameter requiredxint* parameter requiredcchar* parameter required; white-space is not skipped, and NUL-termination is not performedschar* parameter required; string is NUL-terminatede,f,gfloat* parameter requiredpvoid* parameter requirednint* parameter required[...]char* parameter required; string is NUL-terminated[^...]char* parameter required; string is NUL-terminated%%; no assignmentint scanf(const char* format, ...);scanf(f, ...) is equivalent to fscanf(stdin, f, ...)int sscanf(char* s, const char* format, ...);fscanf, but input read from string s.int fgetc(FILE* stream);stream, or EOF on end-of-file or error.char* fgets(char* s, int n, FILE* stream);stream to s, stopping when n-1 characters copied, newline copied, end-of-file reached or error occurs. If no error, s is NUL-terminated. Returns NULL on end-of-file or error, s otherwise.fputc(int c, FILE* stream);c, to stream stream. Returns c, or EOF on error.char* fputs(const char* s, FILE* stream);s, to (output) stream stream. Returns non-negative on success or EOF on error.int getc(FILE* stream);fgetc except that it may be a macro.int getchar(void);getc(stdin).char* gets(char* s);stdin into s until newline encountered, end-of-file reached, or error occurs. Does not copy newline. NUL-terminates s. Returns s, or NULL on end-of-file or error. Should not be used because of the potential for buffer overflow.int putc(int c, FILE* stream);fputc except that it may be a macro.int putchar(int c);putchar(c) is equivalent to putc(c, stdout).int puts(const char* s);s (excluding terminating NUL) and a newline to stdout. Returns non-negative on success, EOF on error.int ungetc(int c, FILE* stream);c (which must not be EOF), onto (input) stream stream such that it will be returned by the next read. Only one character of pushback is guaranteed (for each stream). Returns c, or EOF on error.size_t fread(void* ptr, size_t size, size_t nobj, FILE* stream);nobj objects of size size from stream stream into ptr and returns number of objects read. (feof and ferror can be used to check status.)size_t fwrite(const void* ptr, size_t size, size_t nobj, FILE* stream);stream, nobj objects of size size from array ptr. Returns number of objects written.int fseek(FILE* stream, long offset, int origin);stream and clears end-of-file indicator. For a binary stream, file position is set to offset bytes from the position indicated by origin: beginning of file for SEEK_SET, current position for SEEK_CUR, or end of file for SEEK_END. Behaviour is similar for a text stream, but offset must be zero or, for SEEK_SET only, a value returned by ftell. Returns non-zero on error.long ftell(FILE* stream);stream, or -1 on error.void rewind(FILE* stream);fseek(stream, 0L, SEEK_SET); clearerr(stream).int fgetpos(FILE* stream, fpos_t* ptr);stream in *ptr. Returns non-zero on error.int fsetpos(FILE* stream, const fpos_t* ptr);*ptr. Returns non-zero on error.void clearerr(FILE* stream);stream.int feof(FILE* stream);stream.int ferror(FILE* stream);stream.void perror(const char* s);s (if non-null) and strerror(errno) to standard error as would:fprintf(stderr, "%s: %s\n", (s != NULL ? s : ""), strerror(errno))
[Contents]
EXIT_FAILUREstatus argument to exit indicating failure.EXIT_SUCCESSstatus argument to exit indicating success.RAND_MAXrand().NULLdiv_tdiv(). Structure having members:int quot;
int rem;
ldiv_tldiv(). Structure having members:long quot;
long rem;
size_tsizeof operator.int abs(int n);long labs(long n);n.div_t div(int num, int denom);ldiv_t ldiv(long num, long denom);num/denom.double atof(const char* s);strtod(s, (char**)NULL) except that errno is not necessarily set on conversion error.int atoi(const char* s);(int)strtol(s, (char**)NULL, 10) except that errno is not necessarily set on conversion error.long atol(const char* s);strtol(s, (char**)NULL, 10) except that errno is not necessarily set on conversion error.double strtod(const char* s, char** endp);s to type double. If endp non-null, stores pointer to unconverted suffix in *endp. On overflow, sets errno to ERANGE and returns HUGE_VAL with the appropriate sign; on underflow, sets errno to ERANGE and returns zero; otherwise returns converted value.long strtol(const char* s, char** endp, int base);s to type long. If endp non-nu
ll, stores pointer to unconverted suffix in *endp. If base between 2 and 36, that base used for conversion; if zero, leading (after any sign) 0X or 0x implies hexadecimal, leading 0 (after any sign) implies octal, otherwise decimal assumed. Leading 0X or 0x permitted for base hexadecimal. On overflow, sets errno to ERANGE and returns LONG_MAX or LONG_MIN (as appropriate for sign); otherwise returns converted value.unsigned long strtoul(const char* s, char** endp, int base);strtol except result is unsigned long and value on overflow is ULONG_MAX.void* calloc(size_t nobj, size_t size);nobj objects each of size size, or NULL on error.void* malloc(size_t size);NULL on error.void* realloc(void* p, size_t size);size, initialised, to minimum of old and new sizes, to existing contents of p (if non-null), or NULL on error. On success, old object deallocated, otherwise unchanged.void free(void* p);p non-null, deallocates space to which it points.void abort();raise(SIGABRT).void exit(int status);atexit
are called (in reverse order to that in which installed), open files
are flushed, open streams are closed and control is returned to
environment. status is returned to environment in implementation-dependent manner. Zero or EXIT_SUCCESS indicates successful termination and EXIT_FAILURE indicates unsuccessful termination. Implementations may define other values.int atexit(void (*fcm)(void));fcn to be called when program terminates normally (or when main returns). Returns non-zero on failure.int system(const char* s);s is not NULL, passes s to environment for execution, and returns status reported by command processor; if s is NULL, non-zero returned if environment has a command processor.char* getenv(const char* name);name from implementation's environment, or NULL if no such string exists.void* bsearch(const void* key, const void* base, size_t n, size_t size, int (*cmp)(const void* keyval, const void* datum));base (of n objects each of size size) for item matching key according to comparison function cmp. cmp must return negative value if first argument is less than second, zero if equal and positive if greater. Items of base are assumed to be in ascending order (according to cmp). Returns a pointer to an item matching key, or NULL if none found.void qsort(void* base, size_t n, size_t size, int (*cmp)(const void*, const void*));base (of n objects each of size size) according to comparison function cmp. cmp must return negative value if first argument is less than second, zero if equal and positive if greater.int rand(void);0 to RAND_MAX.void srand(unsigned int seed);seed as seed for new sequence of pseudo-random numbers. Initial seed is 1.[Contents]
NULLsize_tsizeof operator.char* strcpy(char* s, const char* ct);ct to s including terminating NUL and returns s.char* strncpy(char* s, const char* ct, size_t n);n characters of ct to s. Pads with NUL characters if ct is of length less than n. Note that this may leave s without NUL-termination. Return s.char* strcat(char* s, const char* ct);ct to s and return s.char* strncat(char* s, const char* ct, size_t n);n characters of ct to s. NUL-terminates s and return it.int strcmp(const char* cs, const char* ct);cs with ct, returning negative value if cs<ct, zero if cs==ct, positive value if cs>ct.int strncmp(const char* cs, const char* ct, size_t n);n characters of cs and ct, returning negative value if cs<ct, zero if cs==ct, positive value if cs>ct.int strcoll(const char* cs, const char* ct);cs with ct according to locale, returning negative value if cs<ct, zero if cs==ct, positive value if cs>ct.char* strchr(const char* cs, int c);c in cs, or NULL if not found.char* strrchr(const char* cs, int c);c in cs, or NULL if not found.size_t strspn(const char* cs, const char* ct);cs which consists of characters which are in ct.size_t strcspn(const char* cs, const char* ct);cs which consists of characters which are not in ct.char* strpbrk(const char* cs, const char* ct);cs of any character of ct, or NULL if none is found.char* strstr(const char* cs, const char* ct);ct within cs, or NULL if none is found.size_t strlen(const char* cs);cs.char* strerror(int n);n.char* strtok(char* s, const char* t);s for next token delimited by any character from ct. Non-NULL s indicates the first call of a sequence. If a token is found, it is NUL-terminated and returned, otherwise NULL is returned. ct need not be identical for each call in a sequence.size_t strxfrm(char* s, const char* ct, size_t n);s no more than n characters (including terminating NUL) of a string produced from ct according to a locale-specific transformation. Returns length of entire transformed string.void* memcpy(void* s, const void* ct, size_t n);n characters from ct to s and returns s. s may be corrupted if objects overlap.void* memmove(void* s, const void* ct, size_t n);n characters from ct to s and returns s. s will not be corrupted if objects overlap.int memcmp(const void* cs, const void* ct, size_t n);n characters of cs and ct, returning negative value if cs<ct, zero if cs==ct, positive value if cs>ct.void* memchr(const void* cs, int c, size_t n);c in first n characters of cs, or NULL if not found.void* memset(void* s, int c, size_t n);n characters of s by c and returns s.[Contents]
CLOCKS_PER_SECclock_t units per second.NULLclock_ttime_tstruct tmint tm_sec;int tm_min;int tm_hour;int tm_mday;int tm_mon;int tm_year;int tm_wday;int tm_yday;int tm_isdst;clock_t clock(void);-1 if not available.time_t time(time_t* tp);-1 if not available. If tp is non-NULL, return value is also assigned to *tp.double difftime(time_t time2, time_t time1);time2 and time1.time_t mktime(struct tm* tp);*tp to fall withing normal ranges. Returns the corresponding calendar time, or -1 if it cannot be represented.char* asctime(const struct tm* tp);Sun Jan 3 13:08:42 1988\n\0char* ctime(const time_t* tp);tp converted to local time. Equivalent to:asctime(localtime(tp))struct tm* gmtime(const time_t* tp);*tp converted to Coordinated Universal Time, or NULL if not available.struct tm* localtime(const time_t* tp);*tp converted into local
time.size_t strftime(char* s, size_t smax, const char* fmt, const struct tm* tp);*tp into s according to fmt. Places no more than smax characters into s, and returns number of characters produced (excluding terminating NUL), or 0 if greater than smax. Formatting conversions (%c) are:AaBbcd01-31]H00-23]I01-12]j001-366]M00-59]m01-12]pAM" or "PM"S00-61]U00-53]W00-53]w0) [0-6]XxYy00-99]Z%%Local time may differ from calendar time because of time zone.
[Contents]
Copyright University of Tasmania.