/usr/include) can also be very informative.
void assert(int ). If the value in the argument is non-zero, nothing exciting happens. The program continues on. If the argument evaluates to zero, the program dies after printing a message on the standard error file (usually the screen).
The ONLY reasonable use for this function is in debugging. You
assert()s throughout the program, giving
as the argument an expression that you think should be true at
that point in the program. When the program runs, it evaluates
your assertion (expression). If you were wrong, the program
tells you where it's at, dies, and you get to figure out why
your logic was wrong at that point. A very useful
But wait, there's more! If you
#include <assert.h> all of your
assert()s are cheerfully ignored. So you can
enable or disable all of your debugging checking by changing a
int) and return a non-zero or zero value according to whether the character meets or does not meet the given criterion. These functions are usually implemented as lookup tables optimized for each specific architecture, so calling
isupper(c)is much faster than
if(c >= 'A' && c <='Z') ....
int tolower(int c)
int toupper(int c)
unsigned intis 65535 on a PC running DOS, and 4294967295 on a PC running Unix. The maxmimum value of an
unsigned long intis 4294967295 on a Pentium class machine running Unix and 18446744073709551615 on a DEC Alpha machine running Unix.
Many programs break down when ported to different architectures because they make assumptions about the capacity of fundamental types. Using this header file helps eliminate that problem.
These values are all
<limits.h>except for floating point types instead of integers. These
#defined values can vary according to architecture. Very important for portability of numeric processing programs.
double atof(char *),
int atoi(char *), and
long atol(char *)
long strtol(), and
atof()and friends. The integer versions are able to convert numbers of different bases. Each of the str... functions also returns a pointer to the location in the string where it stopped the conversion.
RAND_MAXwhich is a symbolic constant also defined in this file.
void srand(unsigned int)
void * malloc(int)
void * calloc(int n_obj, int size)
n_objobjects, each containing
sizebytes. Also initializes the allocated memory to all zeros. Much faster than using
malloc()and then writing your own loop to clear the memory. If you have to initialize the memory to some complex value,
calloc()is a waste of time.
void * realloc(void * p, int size)