Author : Tom Torfs
Page : << Previous 24 Next >>
value returned by rand(). Minimum 32767.
Functions
void abort(void);
Causes an abnormal program termination. Open files may or may not be closed and temporary files may or may not be removed.
int abs(int j);
Returns the absolute value of the integer j.
int atexit(void (*func)(void));
Registers the function pointed to by func to be called at normal program termination, in the reverse order of their registration. At least 32 such functions can be registered. Returns 0 if successful, nonzero otherwise.
double atof(const char *nptr);
Returns the decimal number in the specified string converted to double representation. Need not set errno on error. See strtod() for a function with better error handling.
int atoi(const char *nptr);
Returns the decimal number in the specified string converted to integer representation. Need not set errno on error. See strtol() for a function with better error handling.
long int atol(const char *nptr);
Returns the decimal number in the specified string converted to long int representation. Need not set errno on error. See strtol() for a function with better error handling.
void *bsearch(const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
Searches an array of nmemb elements of the specified size, pointed to by base and sorted in ascending order by the relevant criterion, for an element that matches the specified key.
The function pointed to by compar is called with as parameters pointers to the key resp. an array element. It must return a strictly negative value if the key comes before the array element, a strictly positive value if the key comes after the array element, or zero if the key matches the array element.
Returns a pointer to a matching array element, or NULL if none is found.
void *calloc(size_t nmemb, size_t size);
Allocates memory for an array of nmemb elements of the specified size and initializes it to all-bits-0. Returns a pointer to the start of the allocated memory if successful, or NULL otherwise. The result of requesting 0 bytes may be either a pointer to 0 bytes of memory or NULL.
div_t div(int numer, int denom);
Divides numer by denom. Returns the quotient and remainder in the quot resp. rem member variables of the returned div_t structure (see above).
void exit(int status);
Causes normal program termination. The functions registered by atexit() are called in the reverse order they were registered in, open files are closed and temporary files are removed. The macros EXIT_SUCCESS and EXIT_FAILURE can be used to indicate successful resp. unsuccessful termination.
void free(void *ptr);
Deallocates the memory pointed to by ptr, which should be a pointer returned by an earlier call to malloc(), calloc() or realloc(). The pointer may not be used afterwards except for assigning a new value to it.
char *getenv(const char *name);
Returns a pointer to a string representing the value of the environment variable specified by name, or NULL if the specified environment variable can't be found. The returned string is read-only and may be overwritten by subsequent calls to getenv().
long int labs(long int j);
Returns the absolute value of the long int j.
ldiv_t ldiv(long int numer, long int denom);
Divides numer by denom. Returns the quotient and remainder in the quot resp. rem member variables of the returned ldiv_t structure (see above).
void *malloc(size_t size);
Allocates size bytes of memory and returns a pointer to the start of the allocated memory if successful, or NULL otherwise. The allocated memory is not initialized and has to be written to before it may be read. The result of requesting 0 bytes may be either a pointer to 0 bytes of memory or NULL.
int mblen(const char *s, size_t n);
If s is NULL, returns nonzero if multibyte characters have state- dependent encodings, 0 otherwise. If s is not NULL, returns the number of bytes that comprise the multibyte character pointed to by s of max. n bytes, or -1 if it is not a valid multibyte character, or 0 if it is the null character.
size_t mbstowcs(wchar_t *pwcs, const char *s, size_t n);
Converts a 0-terminated sequence of multibyte characters into a sequence of upto n corresponding wide character codes. Returns the number of written wide character codes or (size_t)-1 if an invalid multibyte character is encountered.
int mbtowc(wchar_t *pwc, const char *s, size_t n);
The mbtowc() function is analogous to the mblen() function, except that, unless pwc is NULL, it also stores the wide-character code that corresponds to the multibyte character in the wchar_t pointed to by pwc (provided the multibyte character is valid, of course).
int rand(void);
Returns a pseudo-random integer in the range 0..RAND_MAX.
void *realloc(void *ptr, size_t size);
Changes the size of the allocated memory for the specified pointer to the specified size. The contents of the memory will be left intact. Returns a pointer to the newly allocated memory, which may be different from the original pointer. If the returned pointer is NULL, the original memory will still be allocated.
void srand(unsigned int seed);
Initializes a new sequence of pseudo-random numbers with the specified seed. At program startup the seed is 1, so if no call to srand() is made the rand() function will return the same pseudo-random number sequence every time the program is run.
double strtod(const char *nptr, char **endptr);
Returns the decimal number in the string pointed to by nptr, converted to double representation. Leading whitespace is skipped. Unless endptr is NULL, the pointer pointed to by endptr is set to the first character that can't be converted anymore. If no conversion was possible, 0 is returned. If the value is too large, +/- HUGE_VAL is returned; if the value is too small, 0 is returned. In both these cases errno will be set to ERANGE.
long int strtol(const char *nptr, char **endptr, int base);
Returns the base-n number (base must be in the range 2..36) in the string pointed to by nptr, converted to long int representation. Leading whitespace is skipped. Unless endptr is NULL, the pointer pointed to by endptr is set to the first character that can't be converted anymore. If no conversion was possible, 0 is returned. If the value is too large, LONG_MAX or LONG_MIN is returned and errno will be set to ERANGE.
unsigned long int strtoul(const char *nptr, char **endptr,
int base);
The strtoul() function is analogous to strtol(), except that if the value is too large ULONG_MAX will be returned.
int system(const char *string);
Lets the command processor execute the specified string. If string is NULL, returns nonzero if a command processor exists, 0 otherwise. If string is non-NULL, the returned value depends on your system.
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
Sorts in ascending order an array of nmemb elements of the specified size, pointed to by base.
The function pointed to by compar is called with as parameters pointers to two array elements. It must return a strictly negative value if the first element comes before the second, a strictly positive value if the first element comes after the second, or zero if the two elements match (in which case their sorting order is unspecified).
size_t wcstombs(char *s, const wchar_t *pwcs, size_t n);
Converts a 0-terminated sequence of wide character codes into a sequence of upto n bytes of multibyte characters. Returns the number of written bytes or (size_t)-1 if a code not corresponding to a valid multibyte character is encountered.
int wctomb(char *s, wchar_t wchar);
If s is NULL, returns nonzero if multibyte characters have state- dependent encodings, 0 otherwise. If s is not NULL, returns the number of bytes that comprise the multibyte character corresponding to the specified wide character code (less than or equal to MB_CUR_MAX) and stores the multibyte character in the array pointed to by s, or returns -1 if the wide character code does not correspond to a valid multibyte character.16.15. string.h (string handling)
Types
size_t
Explained in 16.12. stddef.h.
Macros
NULL
Explained in 16.12. stddef.h.
Functions
void *memchr(const void *s, int c, size_t n);
Returns a pointer to the first occurence of the character c (converted to unsigned char) in the first n bytes of memory pointed to by s, or NULL if none is found.
int memcmp(const void *s1, const void *s2, size_t n);
Compares the first n characters of the memory pointed to by s1 with the first n characters of the memory pointed to by s2. Returns a strictly negative value if s1 comes before s2, a strictly positive value if s1 comes after s2, or 0 if they match.
void *memcpy(void *s1, const void *s2, size_t n);
Copies n characters from the memory pointed to by s2 to the memory pointed to by s1. The areas
Page : << Previous 24 Next >>