C Source Code Builder

EditRocket provides information on the following C Library routines in the C source code builder included in EditRocket:

assert
ctype
math
signal
stdarg
stddef
stdio
stdlib
string
time

assert

assert(int expression) - Macro used for internal error detection.

ctype

int isalnum(int c) - is c alpha or digit

int isalpha(int c) - is c alpha

int iscntrl(int c) - is control character

int isdigit(int c) - is decimal digit

int isgraph(int c) - is printing character other than space

int islower(int c) - is lower-case letter

int isprint(int c) - is printing character (including space)

int ispunct(int c) - is printing character other than space, letter, digit

int isspace(int c) - is space, formfeed, newline, carriage return, tab, vertical tab

int isupper(int c) - is upper-case letter

int isxdigit(int c) - is hexadecimal digit

int tolower(int c) - return lower-case equivalent

int toupper(int c) - return upper-case equivalent

math

double acos(double x) - arc-cosine of x

double asin(double x) - arc-sine of x

double atan(double x) - arg-tangent of x

double atan2(double y, double x) - arc-tangent of y/x

double ceil(double x) - smallest integer not less than x

double cos(double x) - cosine of x

double cosh(double x) - hyperbolic cosine of x

double exp(double x) - exponential of x

double fabs(double x) - absolute value of x

double floor(double x) - largest integer not greater than x

double fmod(double x, double y) - if y non-zero, floating-point remainder of x/y, with same sign as x; if y zero, result is implementation-defined

double frexp(double x, int* exp) - if 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 zero

double ldexp(double x, int n) - x times 2 to the power n

double log(double x) - natural logarithm of x

double log10(double x) - base-10 logarithm of x

double modf(double x, double* p) - returns fractional part and assigns to *ip integral part of x, both with same sign as x

double modf(double x, double* p) - returns fractional part and assigns to *ip integral part of x, both with same sign as x

double pow(double x, double y) - x raised to power y

double sin(double x) - sine of x

double sinh(double x) - hyperbolic sine of x

double sqrt(double x) - square root of x

double tan(double x) - tangent of x

double tanh(double x) - hyperbolic tangent of x

signal

int raise(int sig) - Sends signal sig. Returns zero on success.

void (*signal(int sig, void (*handler)(int)))(int) - Install handler for subsequent signal sig.

stdarg

type va_arg(va_list ap, type) - Yields value of the type (type) and value of the next unnamed argument.

void va_end(va_list ap) - Termination macro which must be called once after argument processing and before exit from function.

void va_start(va_list ap, lastarg) - Initialisation macro which must be called once before any unnamed argument is accessed.

stddef

offsetof(stype, m) - Offset (in bytes) of member m from start of structure type stype.

stdio

void clearerr(FILE* stream) - Clears end-of-file and error indicators for stream stream.

int fclose(FILE* stream) - Closes stream stream (after flushing, if output stream). Returns EOF on error, zero otherwise.

int feof(FILE* stream) - Returns non-zero if end-of-file indicator is set for stream stream.

int ferror(FILE* stream) - Returns non-zero if error indicator is set for stream stream.

int fflush(FILE* stream) - Flushes stream stream and returns zero on success or EOF on error. Effect undefined for input stream. fflush(NULL) flushes all output streams.

int fgetc(FILE* stream) - Returns next character from (input) stream stream, or EOF on end-of-file or error.

int fgetpos(FILE* stream, fpos_t* ptr) - Stores current file position for stream stream in *ptr. Returns non-zero on error.

char* fgets(char* s, int n, FILE* stream) - Copies characters from (input) 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.

int fprintf(FILE* stream, const char* format, ...) - Converts (according to format format) and writes output to stream stream. Number of characters written, or negative value on error, is returned.

int fputc(int c, FILE* stream) - Writes c, to stream stream. Returns c, or EOF on error.

char* fputs(const char* s, FILE* stream) - Writes s, to (output) stream stream. Returns non-negative on success or EOF on error.

size_t fread(void* ptr, size_t size, size_t nobj, FILE* stream) - Reads (at most) 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.)

FILE* freopen(const char* filename, const char* mode, FILE* stream) - Closes file associated with stream, then opens file filename with specified mode and associates it with stream. Returns stream or NULL on error.

int fscanf(FILE* stream, const char* format, ...) - Performs formatted input conversion, reading from stream 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.

int fseek(FILE* stream, long offset, int origin) - Sets file position for stream 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.

int fsetpos(FILE* stream, const fpos_t* ptr) - Sets current position of stream stream to *ptr. Returns non-zero on error.

long ftell(FILE* stream) - Returns current file position for stream stream, or -1 on error.

size_t fwrite(const void* ptr, size_t size, size_t nobj, FILE* stream) - Writes to stream stream, nobj objects of size size from array ptr. Returns number of objects written.

int getc(FILE* stream) - Equivalent to fgetc except that it may be a macro.

int getchar(void) - Equivalent to getc(stdin).

char* gets(char* s) - Copies characters from 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.

void perror(const char* s) - Prints s (if non-null) and strerror(errno) to standard error.

int printf(const char* format, ...) - printf(f, ...) is equivalent to fprintf(stdout, f, ...)

int putc(int c, FILE* stream) - Equivalent to 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) - Writes s (excluding terminating NUL) and a newline to stdout. Returns non-negative on success, EOF on error.

int remove(const char* filename) - Removes specified file. Returns non-zero on failure.

int rename(const char* oldname, const char* newname) - Changes name of file oldname to newname. Returns non-zero on failure.

void rewind(FILE* stream) - Equivalent to fseek(stream, 0L, SEEK_SET); clearerr(stream).

int scanf(const char* format, ...) - scanf(f, ...) is equivalent to fscanf(stdin, f, ...)

void setbuf(FILE* stream, char* buf) - Controls buffering for stream stream. For null buf, turns off buffering, otherwise equivalent to (void)setvbuf(stream, buf, _IOFBF, BUFSIZ).

int setvbuf(FILE* stream, char* buf, int mode, size_t size) - Controls buffering for stream 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.

int sprintf(char* s, const char* format, ...) - Like fprintf, but output written into string 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 sscanf(char* s, const char* format, ...) - Like fscanf, but input read from string s.

FILE* tmpfile() - Creates temporary file (mode "wb+") which will be removed when closed or on normal program termination. Returns stream or NULL on failure.

char* tmpnam(char s[L_tmpnam]) - Assigns to 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 ungetc(int c, FILE* stream) - Pushes 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.

int vfprintf(FILE* stream, const char* format, va_list arg) - Equivalent to 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);\ - Equivalent to 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) - Equivalent to 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).

stdlib

void abort() - Terminates program abnormally, by calling raise(SIGABRT).

int abs(int n) or long abs(long n) - Returns absolute value of n.

int atexit(void (*fcm)(void)) - Registers fcn to be called when program terminates normally (or when main returns). Returns non-zero on failure.

double atof(const char* s) - Equivalent to strtod(s, (char**)NULL) except that errno is not necessarily set on conversion error.

int atoi(const char* s) - Equivalent to (int)strtol(s, (char**)NULL, 10) except that errno is not necessarily set on conversion error.

long atol(const char* s) - Equivalent to strtol(s, (char**)NULL, 10) except that errno is not necessarily set on conversion error.

void* bsearch(const void* key, const void* base, size_t n, size_t size, int (*cmp)(const void* keyval, const void* datum)) - Searches ordered array 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* calloc(size_t nobj, size_t size) - Returns pointer to zero-initialised newly-allocated space for an array of nobj objects each of size size, or NULL on error.

div(int num, int denom) - Returns quotient and remainder of num/denom.

void exit(int status) - Terminates program normally. Functions installed using 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.

void free(void* p) - If p non-null, deallocates space to which it points.

char* getenv(const char* name) - Returns string associated with name name from implementation's environment, or NULL if no such string exists.

ldiv(long num, long denom) - Returns quotient and remainder of num/denom.

void* malloc(size_t size) - Returns pointer to uninitialised newly-allocated space for an object of size size, or NULL on error.

void qsort(void* base, size_t n, size_t size, int (*cmp)(const void*, const void*)) - Arranges into ascending order array 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); - Returns pseudo-random number in range 0 to RAND_MAX.

void* realloc(void* p, size_t size) - Returns pointer to newly-allocated space for an object of 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 srand(unsigned int seed) - Uses seed as seed for new sequence of pseudo-random numbers. Initial seed is 1.

double strtod(const char* s, char** endp) - Converts initial characters (ignoring leading white space) of 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) - Converts initial characters (ignoring leading white space) of 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) - As for strtol except result is unsigned long and value on overflow is ULONG_MAX.

int system(const char* s) - If 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.

string

void* memchr(const void* cs, int c, size_t n); - Returns pointer to first occurrence of c in first n characters of cs, or NULL if not found.

int memcmp(const void* cs, const void* ct, size_t n) - Compares at most (the first) n characters of cs and ct, returning negative value if csct.

void* memcpy(void* s, const void* ct, size_t n) - Copies 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) - Copies n characters from ct to s and returns s. s will not be corrupted if objects overlap.

void* memset(void* s, int c, size_t n) - Replaces each of the first n characters of s by c and returns s.

char* strcat(char* s, const char* ct); - Concatenate ct to s and return s.

char* strchr(const char* cs, int c) - Returns pointer to first occurrence of c in cs, or NULL if not found.

int strcmp(const char* cs, const char* ct) - Compares cs with ct, returning negative value if csct.

int strcoll(const char* cs, const char* ct) - Compares cs with ct according to locale, returning negative value if csct.

char* strcpy(char* s, const char* ct) - Copies ct to s including terminating NUL and returns s.

size_t strcspn(const char* cs, const char* ct) - Returns length of prefix of cs which consists of characters which are not in ct.

char* strerror(int n) - Returns pointer to implementation-defined message string corresponding with error n.

size_t strlen(const char* cs) - Returns length of cs.

char* strncat(char* s, const char* ct, size_t n) - Concatenate at most n characters of ct to s. NUL-terminates s and return it.

int strncmp(const char* cs, const char* ct, size_t n) - Compares at most (the first) n characters of cs and ct, returning negative value if csct.

char* strncpy(char* s, const char* ct, size_t n) - Copies at most 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* strpbrk(const char* cs, const char* ct) - Returns pointer to first occurrence in cs of any character of ct, or NULL if none is found.

char* strrchr(const char* cs, int c) - Returns pointer to last occurrence of c in cs, or NULL if not found.

size_t strspn(const char* cs, const char* ct) - Returns length of prefix of cs which consists of characters which are in ct.

char* strstr(const char* cs, const char* ct) - Returns pointer to first occurrence of ct within cs, or NULL if none is found.

char* strtok(char* s, const char* t) - Searches 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) - Stores in 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.

time

char* asctime(const struct tm* tp); - Returns the given time as a string of the form: Sun Jan 3 13:08:42 1988\n\0

clock_t clock(void) - Returns elapsed processor time used by program or -1 if not available.

char* ctime(const time_t* tp); - Returns string equivalent to calendar time tp converted to local time.

double difftime(time_t time2, time_t time1) - Returns the difference in seconds between time2 and time1.

struct tm* gmtime(const time_t* tp) - Returns calendar time *tp converted to Coordinated Universal Time, or NULL if not available.

struct tm* localtime(const time_t* tp) - Returns calendar time *tp converted into local time.

time_t mktime(struct tm* tp) - If necessary, adjusts fields of *tp to fall withing normal ranges. Returns the corresponding calendar time, or -1 if it cannot be represented.

size_t strftime(char* s, size_t smax, const char* fmt, const struct tm* tp) - Formats *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.

time_t time(time_t* tp) - Returns current calendar time or -1 if not available. If tp is non-NULL, return value is also assigned to *tp.