NeatInfo.

com - by Jan Zumwalt

Pg 1 of 35
Copyright ©1995-2012

February 10, 2012

Table of Contents
Table of ContentsQuick Reference................................................................................................................. 2 Quick Reference .............................................................................................................................................. 4 String Functions .............................................................................................................................................. 6 char *strcpy( char *s1, const char *s2) ........................................................................................................... 6 char *strncpy( char *s1, const char *s2, size_t n)............................................................................................ 6 char *strcat( char *s1, const char *s2) ............................................................................................................ 7 char *strncat( char *s1, const char *s2, size_t n) ............................................................................................ 7 char *strchr( const char *s, int c) ................................................................................................................... 8 char *strrchr( const char *s, int c) .................................................................................................................. 8 int strcmp( const char *s1, const char *s2) ..................................................................................................... 8 int stricmp( const char *s1, const char *s2)..................................................................................................... 9 int strncmp( const char *s1, const char *s2, size_t n)...................................................................................... 9 size_t strspn( char *s1, const char *s2) .......................................................................................................... 9 size_t strcspn( char *s1, const char *s2)......................................................................................................... 9 size_t strlen( const char *s)............................................................................................................................ 9 char *strpbrk( const char *s1, const char *s2).............................................................................................. 10 char *strstr( const char *s1, const char *s2)................................................................................................. 10 char *strtok(char *s1, const char *s2) ........................................................................................................... 10 char * strlwr(char *s1), char * strupr(char *s1) .............................................................................................. 10 Math Functions .............................................................................................................................................. 12 double pow ( double, double ) - power of...................................................................................................... 12 double sqrt( double ) - square root .............................................................................................................. 13 double ceil ( double ) - if decimal part exists, returns the next bigger integer................................................. 13 double floor ( double ) - removes the decimal part of the argument............................................................... 13 double round ( double ) - rounds the argument............................................................................................. 13 double fmin ( double, double ) - returns the smaller argument ...................................................................... 13 double fmax ( double, double ) - returns the bigger argument ....................................................................... 13 double fabs( double ) - returns the absolute value of the argument.............................................................. 13 double acos(double x);................................................................................................................................. 13 double asin(double x);.................................................................................................................................. 13 double atan(double x); ................................................................................................................................. 13 double atan2(double y, double x); ................................................................................................................ 14 double cos(double x); .................................................................................................................................. 14 double sin(double x); ................................................................................................................................... 14 double tan(double x); ................................................................................................................................... 14 double cosh(double x);................................................................................................................................. 14 double sinh(double x);.................................................................................................................................. 14 double tanh(double x); ................................................................................................................................. 14 double exp(double x); .................................................................................................................................. 14 double frexp(double value, int *exp); ............................................................................................................ 14 double ldexp(double x, int exp); ................................................................................................................... 14 double log(double x); ................................................................................................................................... 14 double log10(double x); ............................................................................................................................... 15 double modf(double value, double *iptr); ...................................................................................................... 15 double pow(double x, double y); .................................................................................................................. 15 double sqrt(double x); .................................................................................................................................. 15 double ceil(double x);................................................................................................................................... 15 double fabs(double x); ................................................................................................................................. 15 double floor(double x); ................................................................................................................................. 15 double fmod(double x, double y); ................................................................................................................. 15 Code Examples.............................................................................................................................................. 20 void main()................................................................................................................................................... 20 Printf............................................................................................................................................................ 20 Scanf........................................................................................................................................................... 20 Conditionals................................................................................................................................................. 20 Looping ....................................................................................................................................................... 20 Math Functions ............................................................................................................................................ 21
NeatInfo.com - by Jan Zumwalt

Pg 2 of 35
Copyright ©1995-2012

February 10, 2012

Creating Functions....................................................................................................................................... 21 ISO C library headers .................................................................................................................................... 22 <assert.h> ................................................................................................................................................... 23 <ctype.h> .................................................................................................................................................... 23 <errno.h>..................................................................................................................................................... 23 <float.h> ...................................................................................................................................................... 23 <limits.h>..................................................................................................................................................... 24 <locale.h>.................................................................................................................................................... 24 <math.h> ..................................................................................................................................................... 24 <setjmp.h>................................................................................................................................................... 25 <signal.h>.................................................................................................................................................... 25 <stdarg.h> ................................................................................................................................................... 26 <stddef.h> ................................................................................................................................................... 26 <stdio.h> ..................................................................................................................................................... 26 <stdlib.h>..................................................................................................................................................... 29 <string.h> .................................................................................................................................................... 30 <time.h> ...................................................................................................................................................... 31 Naming Conventions ..................................................................................................................................... 33 Class specific .............................................................................................................................................. 33 Generic Naming Conventions ...................................................................................................................... 33 Definitions ................................................................................................................................................... 33 Access (visibility) ......................................................................................................................................... 34

NeatInfo.com - by Jan Zumwalt

Pg 3 of 35
Copyright ©1995-2012

February 10, 2012

Quick Reference

NeatInfo.com - by Jan Zumwalt

Pg 4 of 35
Copyright ©1995-2012

February 10, 2012

NeatInfo.com - by Jan Zumwalt

Pg 5 of 35
Copyright ©1995-2012

February 10, 2012

String Functions
char *strcpy( char *s1, const char *s2)
Copies the string s2 into the character array s1. The value of s1 is returned. The "strcpy" function copies one string from another. For example:
/* strcpy.c */ #include <stdio.h> #include <string.h> void main() { char s1[100], s2[100]; strcpy( s1, "string 1" ); strcpy( s2, "string 2" ); puts( puts( puts( puts( puts( "Original strings: " ); "" ); s1 ); s2 ); "" );

strcpy( s2, s1 ); puts( puts( puts( puts( } "New strings: " ); "" ); s1 ); s2 );

Result:
Original strings: string 1 string 2 New strings: string 1 string 1

Please be aware of two features of this program: This program assumes that "s1" has enough space to store the final string. The "strcpy()" function won't bother to check, and will give erroneous results if that is not the case. A string constant can be used as the source string instead of a string variable. Using a string constant for the destination, of course, makes no sense. These comments are applicable to most of the other string functions.

char *strncpy( char *s1, const char *s2, size_t n)
NeatInfo.com - by Jan Zumwalt

Pg 6 of 35
Copyright ©1995-2012

February 10, 2012

copies at most n characters of the string s2 into the character array s1. The value of s1 is returned.

There is a variant form of "strcpy" named "strncpy" that will copy "n" characters of the source string to the destination string, presuming there are that many characters available in the source string. For example, if the following change is made in the example program:
strncpy( s2, s1, 5

);

Result:
New strings: string 1 string

Notice that the parameter "n" is declared "size_t", which is defined in "string.h". char *strcat( char *s1, const char *s2)
Appends the string s2 to the end of character array s1. The first character from s2 overwrites the '###BOT_TEXT###' of s1. The value of s1 is returned.

The "strcat()" function joins two strings:
/* strcat.c */ #include <stdio.h> #include <string.h> void main() { char s1[50], s2[50]; strcpy( s1, "Tweedledee " ); strcpy( s2, "Tweedledum" ); strcat( s1, s2 ); puts( s1 ); } Result:
Tweedledee Tweedledum

char *strncat( char *s1, const char *s2, size_t n)
Appends at most n characters of the string s2 to the end of character array s1. The first character from s2 overwrites the '###BOT_TEXT###' of s1. The value of s1 is returned. There is a variant version of "strcat()" named "strncat()" that will append "n" characters of the source string to the destination string. If the example above used "strncat()" with a length of 7:
strncat( s1, s2, 7

);

Result:
NeatInfo.com - by Jan Zumwalt

Pg 7 of 35
Copyright ©1995-2012

February 10, 2012

Tweedledee Tweedle

Again, the length parameter is of type "size_t". char *strchr( const char *s, int c)
Returns a pointer to the first instance of c in s. Returns a NULL pointer if c is not encountered in the string.

The "strchr" function finds the first occurrence of a character in a string. It returns a pointer to the character if it finds it, and null if not. For example:
/* strchr.c */ #include <stdio.h> #include <string.h> void main() { char *t = "MEAS:VOLT:DC?"; char *p; p = t; puts( p ); while(( p = strchr( p, ':' )) != NULL ) { puts( ++p ); } } Result:
MEAS:VOLT:DC? VOLT:DC? DC?

The character is defined as a character constant, which C regards as an "int". Notice how the example program increments the pointer before using it ("++p") so that it doesn't point to the ":" but to the character following it.

char *strrchr( const char *s, int c)
Returns a pointer to the last instance of c in s. Returns a NULL pointer if c is not encountered in the string.

int strcmp( const char *s1, const char *s2)
Compares the string s1 to the string s2. The function returns 0 if they are the same, a number < 0 if s1 < s2, a number > 0 if s1 > s2.
The "strcmp()" function compares two strings:

/* strcmp.c */ #include <stdio.h> #include <string.h>
NeatInfo.com - by Jan Zumwalt

Pg 8 of 35
Copyright ©1995-2012

February 10, 2012

#define ANSWER "blue" void main() { char t[100]; puts( "What is the secret color?" ); gets( t ); while ( strcmp( t, ANSWER ) != 0 ) { puts( "Wrong, try again." ); gets( t ); } puts( "Right!" ); }

The "strcmp()" function returns a 0 for a successful comparison, and nonzero otherwise. The comparison is case-sensitive, so answering "BLUE" or "Blue" won't work. There are three alternate forms for "strcmp()": int stricmp( const char *s1, const char *s2)
compares the string s1 to the string s2. The function returns 0 if they are the same, a number < 0 if s1 < s2, a number > 0 if s1 > s2.

A "stricmp()" function that ignores case in comparisons.

int strncmp( const char *s1, const char *s2, size_t n)
compares up to n characters of the string s1 to the string s2. The function returns 0 if they are the same, a number < 0 ifs1 < s2, a number > 0 if s1 > s2.

A "strncmp()" function which, as might be guessed, compares "n" characters
in the source string with the destination string: "strncmp( s1, s2, 6 )".

size_t strspn( char *s1, const char *s2)
returns the length of the longest substring of s1 that begins at the start of s1and consists only of the characters found in s2.

size_t strcspn( char *s1, const char *s2)
returns the length of the longest substring of s1 that begins at the start of s1and contains none of the characters found in s2.

size_t strlen( const char *s)
determines the length of the string s. Returns the number of characters in the string before the '###BOT_TEXT###'.

The "strlen()" function gives the length of a string, not including the NULL character at the end:
NeatInfo.com - by Jan Zumwalt

Pg 9 of 35
Copyright ©1995-2012

February 10, 2012

/* strlen.c */ #include <stdio.h> #include <string.h> void main() { char *t = "XXX"; printf( "Length of <%s> is %d.\n", t, strlen( t )); } Result:
Length of <XXX> is 3.

char *strpbrk( const char *s1, const char *s2)
returns a pointer to the first instance in s1 of any character found in s2. Returns a NULL pointer if no characters from s2 are encountered in s1.

char *strstr( const char *s1, const char *s2)
returns a pointer to the first instance of string s2 in s1. Returns a NULL pointer if s2 is not encountered in s1. The "strstr()" function is similar to "strchr()" except that it searches for a string, instead of a character. It also returns a pointer: char *s = "Black White Brown Blue Green";
...

puts( strstr( s, "Blue" ) );

char *strtok(char *s1, const char *s2) char * strlwr(char *s1), char * strupr(char *s1)
The "strlwr()" and "strupr()" functions simply perform lowercase or uppercase conversion on the source string. These two functions are only implemented in some compilers and are not part of ANSI C. /* casecvt.c */ #include <stdio.h> #include <string.h> void main() { char *t = "Die Barney die!"; puts( strlwr( t ) ); puts( strupr( t ) ); } Result:
NeatInfo.com - by Jan Zumwalt

Pg 10 of 35
Copyright ©1995-2012

February 10, 2012

die barney die! DIE BARNEY DIE!

NeatInfo.com - by Jan Zumwalt

Pg 11 of 35
Copyright ©1995-2012

February 10, 2012

Math Functions
abort() abs() acos() asin() atan() atexit() atof() atoi() atol() ceil() clock() cosh() ctime() div() exit() fabs() floor() fmod() getchar() getenv() isalnum() isalpha() isdigit() isgraph() ispunct() isspace() isupper() kbhit() log10() log2() log() memcmp() modf() pow() putchar() putenv() puts() rand() remove() rename() sinh() sqrt() srand() strcat() strcmp() strerror() time() tolower() toupper()

double pow ( double, double ) - power of
NeatInfo.com - by Jan Zumwalt

Pg 12 of 35
Copyright ©1995-2012

February 10, 2012

NSLog(@"%.f", pow(3,2) ); //result 9 NSLog(@"%.f", pow(3,3) ); //result 27

double sqrt( double ) - square root
NSLog(@"%.f", sqrt(16) ); //result 4 NSLog(@"%.f", sqrt(81) ); //result 9

double ceil ( double ) - if decimal part exists, returns the next bigger integer
NSLog(@"res: %.f", ceil(3.000000000001)); //result 4 NSLog(@"res: %.f", ceil(3.00)); //result 3

double floor ( double ) - removes the decimal part of the argument
NSLog(@"res: %.f", floor(3.000000000001)); //result 3 NSLog(@"res: %.f", floor(3.9999999)); //result 3

double round ( double ) - rounds the argument
NSLog(@"res: %.f", round(3.5)); //result 4 NSLog(@"res: %.f", round(3.46)); //result 3 NSLog(@"res: %.f", round(-3.5)); //NB: this one returns -4

double fmin ( double, double ) - returns the smaller argument
NSLog(@"res: %.f", fmin(5,10)); //result 5

double fmax ( double, double ) - returns the bigger argument
NSLog(@"res: %.f", fmax(5,10)); //result 10

double fabs( double ) - returns the absolute value of the argument
NSLog(@"res: %.f", fabs(10)); //result 10 NSLog(@"res: %.f", fabs(-10)); //result 10

double acos(double x); Principal value of the arc cosine of x in the range 0–π radians. Errors: EDOM if x is not in the range −1–1. double asin(double x); Principal value of the arc sine of x in the range -π/2–+π/2 radians. Errors: EDOM if x is not in the range −1–1. double atan(double x); Principal value of the arc tangent of x in the range -π/2–+π/2 radians.
NeatInfo.com - by Jan Zumwalt

Pg 13 of 35
Copyright ©1995-2012

February 10, 2012

double atan2(double y, double x); Principal value of the arc tangent of y/x in the range -π–+π radians, using the signs of both arguments to determine the quadrant of the return value. Errors: EDOM may occur if both x and y are zero. double cos(double x); Cosine of x (x measured in radians). double sin(double x); Sine of x (x measured in radians). double tan(double x); Tangent of x (x measured in radians). When a range error occurs, the sign of the resulting HUGE_VAL is not guaranteed to be correct. double cosh(double x); Hyperbolic cosine of x. Errors: ERANGE occurs if the magnitude of x is too large. double sinh(double x); Hyperbolic sine of x. Errors: ERANGE occurs if the magnitude of x is too large. double tanh(double x); Hyperbolic tangent of x. double exp(double x); Exponential function of x. Errors: ERANGE occurs if the magnitude of x is too large. double frexp(double value, int *exp); Break a floating point number into a normalized fraction and an integral power of two. This integer is stored in the object pointed to by exp. double ldexp(double x, int exp); Multiply x by 2 to the power exp Errors: ERANGE may occur. double log(double x);
NeatInfo.com - by Jan Zumwalt

Pg 14 of 35
Copyright ©1995-2012

February 10, 2012

Natural logarithm of x. Errors: EDOM occurs if x is negative. ERANGE may occur if x is zero. double log10(double x); Base-ten logarithm of x. Errors: EDOM occurs if x is negative. ERANGE may occur if x is zero. double modf(double value, double *iptr); Break the argument value into integral and fractional parts, each of which has the same sign as the argument. It stores the integrbal part as a double in the object pointed to by iptr, and returns the fractional part. double pow(double x, double y); Compute x to the power y. Errors: EDOM occurs if x < 0 and y not integral, or if the result cannot be represented if x is 0, and y ≤ 0. ERANGE may also occur. double sqrt(double x); Compute the square root of x. Errors: EDOM occurs if x is negative. double ceil(double x); Smallest integer not less than 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); Floating point remainder of x/y. Errors: If y is zero, it is implementation defined whether fmod returns zero or a domain error occurs.
double float double float long double long double double acos(double); acosf(float); acosh(double); acoshf(float); acoshl(long double); acosl(long double); asin(double); Pg 15 of 35
Copyright ©1995-2012 February 10, 2012

NeatInfo.com - by Jan Zumwalt

float double float long double long double double double float long double float double float long double long double double float long double double float long double double float long double double float double float long double long double double double float long double float long double double double float long double float long double double float long double double float long double double float long double double float long double double float long double double float long double double

asinf(float); asinh(double); asinhf(float); asinhl(long double); asinl(long double); atan(double); atan2(double, double); atan2f(float, float); atan2l(long double, long double); atanf(float); atanh(double); atanhf(float); atanhl(long double); atanl(long double); cbrt(double); cbrtf(float); cbrtl(long double); ceil(double); ceilf(float); ceill(long double); copysign(double, double); copysignf(float, float); copysignl(long double, long double); cos(double); cosf(float); cosh(double); coshf(float); coshl(long double); cosl(long double); erf(double); erfc(double); erfcf(float); erfcl(long double); erff(float); erfl(long double); exp(double); exp2(double); exp2f(float); exp2l(long double); expf(float); expl(long double); expm1(double); expm1f(float); expm1l(long double); fabs(double); fabsf(float); fabsl(long double); fdim(double, double); fdimf(float, float); fdiml(long double, long double); floor(double); floorf(float); floorl(long double); fma(double, double, double); fmaf(float, float, float); fmal(long double, long double, long double); fmax(double, double); fmaxf(float, float); fmaxl(long double, long double); fmin(double, double); Pg 16 of 35
Copyright ©1995-2012 February 10, 2012

NeatInfo.com - by Jan Zumwalt

float long double double float long double double float long double double float long double int int int
[XSI]

fminf(float, float); fminl(long double, long double); fmod(double, double); fmodf(float, float); fmodl(long double, long double); frexp(double, int *); frexpf(float value, int *); frexpl(long double value, int *); hypot(double, double); hypotf(float, float); hypotl(long double, long double); ilogb(double); ilogbf(float); ilogbl(long double); j0(double); j1(double); jn(int, double); ldexp(double, int); ldexpf(float, int); ldexpl(long double, int); lgamma(double); lgammaf(float); lgammal(long double); llrint(double); llrintf(float); llrintl(long double); llround(double); llroundf(float); llroundl(long double); log(double); log10(double); log10f(float); log10l(long double); log1p(double); log1pf(float); log1pl(long double); log2(double); log2f(float); log2l(long double); logb(double); logbf(float); logbl(long double); logf(float); logl(long double); lrint(double); lrintf(float); lrintl(long double); lround(double); lroundf(float); lroundl(long double); modf(double, double *); modff(float, float *); modfl(long double, long double *); nan(const char *); nanf(const char *); nanl(const char *); nearbyint(double); nearbyintf(float); Pg 17 of 35
Copyright ©1995-2012 February 10, 2012

double double double double float long double double float long double long long long long long long long long long long long long double double float long double double float long double double float long double double float long double float long double long long long long long long double float long double double float long double double float

NeatInfo.com - by Jan Zumwalt

long double double float long double double float long double double float long double double float long double double float long double double float long double double float long double
[XSI]

nearbyintl(long double); nextafter(double, double); nextafterf(float, float); nextafterl(long double, long double); nexttoward(double, long double); nexttowardf(float, long double); nexttowardl(long double, long double); pow(double, double); powf(float, float); powl(long double, long double); remainder(double, double); remainderf(float, float); remainderl(long double, long double); remquo(double, double, int *); remquof(float, float, int *); remquol(long double, long double, int *); rint(double); rintf(float); rintl(long double); round(double); roundf(float); roundl(long double); scalb(double, double); scalbln(double, long); scalblnf(float, long); scalblnl(long double, long); scalbn(double, int); scalbnf(float, int); scalbnl(long double, int); sin(double); sinf(float); sinh(double); sinhf(float); sinhl(long double); sinl(long double); sqrt(double); sqrtf(float); sqrtl(long double); tan(double); tanf(float); tanh(double); tanhf(float); tanhl(long double); tanl(long double); tgamma(double); tgammaf(float); tgammal(long double); trunc(double); truncf(float); truncl(long double); y0(double); y1(double); yn(int, double);

double double float long double double float long double double float double float long double long double double float long double double float double float long double long double double float long double double float long double
[XSI]

double double double

NeatInfo.com - by Jan Zumwalt

Pg 18 of 35
Copyright ©1995-2012

February 10, 2012

The following external variable shall be defined:
[XSI]

extern int signgam;

NeatInfo.com - by Jan Zumwalt

Pg 19 of 35
Copyright ©1995-2012

February 10, 2012

Code Examples
void main()
void main(void) { }

Printf
#include <stdio.h> void main(void) { int i = 1; unsigned u = 2; long l = 3; float f = 4.0; double d = 5.0; char c = 6; unsigned char uc = 7; printf("i = %d, u = %u, l = %l, f = %f, d = %lf, c = %c, c = %d, uc = %d\n", i, u, l, f, d, c, c, uc); printf("print a tab by \t and new line by \n"); }

Scanf
#include <stdio.h> void main(void) { int i; printf("Print a prompt for i\n"); scanf("%d", &i); }

Conditionals
if(flag) { // put some statements here to execute if flag is true (flag != 0) } if(flag) { // put some statements here to execute if flag is true (flag != 0) } else { // put some statements here to execute if flag is false (flag == 0) } switch(flag) { case 0: // statements break; case 1: // statements break; case 2: // statements break; default: // statements }

Looping while(flag) { // make sure there is some statement in here to change flag to become false. }
NeatInfo.com - by Jan Zumwalt

Pg 20 of 35
Copyright ©1995-2012

February 10, 2012

for(i = 0; i < LAST; i++) { // statements } Math Functions #include <math.h> void main(void) { double th = pi/2; double x, y; x = cos(th); y = sin(th); th = atan2(y, x); } Creating Functions int functionname(type1 input1, ... , typeN *output1, ...); the ; int functionname(type1 input1, ... , typeN *output1, ...) { *output1 = // some function of the input variables. *output2 = // some function of the input varialbles. ... return(someintvalue); } // this is the function prototype with

// th is in radians

NeatInfo.com - by Jan Zumwalt

Pg 21 of 35
Copyright ©1995-2012

February 10, 2012

ISO C library headers
Name <assert.h> <complex.h> C99 <ctype.h> <errno.h> <fenv.h> C99 From Description Contains the assert macro, used to assist with detecting logical errors and other types of bug in debugging versions of a program. A set of functions for manipulating complex numbers. Contains functions used to classify characters by their types or to convert between upper and lower case in a way that is independent of the used character set (typically ASCII or one of its extensions, although implementations utilizing EBCDIC are also known). For testing error codes reported by library functions. For controlling floating-point environment. Contains defined constants specifying the implementation-specific properties of the floating-point library, such as the minimum difference between two different floating-point numbers (_EPSILON), the maximum number of digits of accuracy (_DIG) and the range of numbers which can be represented (_MIN, _MAX). For precise conversion between integer types.

<float.h>

<inttypes.h> C99 <iso646.h> <limits.h> <locale.h> <math.h> <setjmp.h> <signal.h> <stdarg.h> <stdbool.h> <stdint.h> <stddef.h> <stdio.h> <stdlib.h> <string.h> <tgmath.h> <time.h> <wchar.h> <wctype.h> NA1 C99 C99 C99

NA1 For programming in ISO 646 variant character sets. Contains defined constants specifying the implementation-specific properties of the integer types, such as the range of numbers which can be represented (_MIN, _MAX). For setlocale and related constants. This is used to choose an appropriate locale. For computing common mathematical functions. Declares the macros setjmp and longjmp, which are used for non-local exits. For controlling various exceptional conditions. For accessing a varying number of arguments passed to functions. For a boolean data type. For defining various integer types. For defining several useful types and macros. Provides the core input and output capabilities of the C language. This file includes the venerable printf function. For performing a variety of operations, including conversion, pseudo-random numbers, memory allocation, process control, environment, signalling, searching, and sorting. For manipulating several kinds of strings. For type-generic mathematical functions. For converting between various time and date formats. For manipulating wide streams and several kinds of strings using wide characters - key to supporting a range of languages.

NA1 For classifying wide characters.

NeatInfo.com - by Jan Zumwalt

Pg 22 of 35
Copyright ©1995-2012

February 10, 2012

<assert.h>
void assert(int expression); Macro used for internal error detection. (Ignored if 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__. isalpha(c) or isdigit(c) isupper(c) or islower(c) is control character. In ASCII, control characters are 0x00 (NUL) to 0x1F (US), and 0x7F (DEL) is decimal digit is printing character other than space is lower-case letter is printing character (including space). In ASCII, printing characters are 0x20 (' ') to 0x7E ('~') is printing character other than space, letter, digit is space, formfeed, newline, carriage return, tab, vertical tab is upper-case letter is hexadecimal digit return lower-case equivalent return upper-case equivalent object to which certain library functions assign specific positive values on error code used for domain errors code used for range errors other implementation-defined error values are permitted to determine the value (if any) assigned to errno by a library function, a program should assign zero to errno immediately prior to the function call

<ctype.h>
int isalnum(int c); int isalpha(int c); int iscntrl(int c); int isdigit(int c); int isgraph(int c); int islower(int c); int isprint(int c); int ispunct(int c); int isspace(int c); int isupper(int c); int isxdigit(int c); int tolower(int c); int toupper(int c);

<errno.h>
Errno EDOM ERANGE Notes:

<float.h>
Where the prefix "FLT" = float "DBL" = double "LDBL" = long double

FLT_RADIX FLT_ROUNDS FLT_DIG DBL_DIG LDBL_DIG FLT_EPSILON DBL_EPSILON LDBL_EPSILON FLT_MANT_DIG DBL_MANT_DIG LDBL_MANT_DIG FLT_MAX DBL_MAX LDBL_MAX FLT_MAX_EXP DBL_MAX_EXP LDBL_MAX_EXP FLT_MIN DBL_MIN NeatInfo.com - by Jan Zumwalt

radix of floating-point representations floating-point rounding mode

precision (in decimal digits)

smallest number x such that 1.0 + x != 1.0

number of digits, base FLT_RADIX, in mantissa

maximum number

largest positive integer exponent to which FLT_RADIX can be raised and remain representable

Pg 23 of 35
Copyright ©1995-2012

February 10, 2012

LDBL_MIN FLT_MIN_EXP DBL_MIN_EXP LDBL_MIN_EXP

minimum normalised number

smallest negative integer exponent to which FLT_RADIX can be raised and remain representable number of bits in a char maximum value of type char minimum value of type char maximum value of type signed char minimum value of type signed char maximum value of type unsigned char maximum value of type short minimum value of type short maximum value of type unsigned short maximum value of type int minimum value of type int maximum value of type unsigned int maximum value of type long minimum value of type long maximum value of type unsigned long

<limits.h>
CHAR_BIT CHAR_MAX CHAR_MIN SCHAR_MAX SCHAR_MIN UCHAR_MAX SHRT_MAX SHRT_MIN USHRT_MAX INT_MAX INT_MIN UINT_MAX LONG_MAX LONG_MIN ULONG_MAX

<locale.h>
Describes formatting of monetary and other numeric values: decimal point for non-monetary values sizes of digit groups for non-monetary values separator for digit groups for non-monetary values (left of "decimal point") currency symbol international currency symbol decimal point for monetary values sizes of digit groups for monetary values separator for digit groups for monetary values (left of "decimal point") negative sign for monetary values positive sign for monetary values number of digits to be displayed to right of "decimal point" for monetary values number of digits to be displayed to right of "decimal point" for international monetary values char n_cs_precedes; whether currency symbol precedes (1) or follows (0) negative monetary values char n_sep_by_space; whether currency symbol is (1) or is not (0) separated by space from negative monetary values char n_sign_posn; format for negative monetary values: 0 parentheses surround quantity and currency symbol 1 sign precedes quantity and currency symbol 2 sign follows quantity and currency symbol 3 sign immediately precedes currency symbol 4 sign immediately follows currency symbol char p_cs_precedes; whether currency symbol precedes (1) or follows (0) positive monetary values char p_sep_by_space; whether currency symbol is (1) or is not (0) separated by space from non-negative monetary values char p_sign_posn; format for non-negative monetary values, with values as for n_sign_posn Implementations may change field order and include additional fields. Standard C Library functions use only decimal_point. struct lconv* localeconv(void); returns pointer to formatting information for current locale char* setlocale(int category, const char* locale); Sets components of locale according to specified 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_ALL category argument for all categories LC_NUMERIC category for numeric formatting information LC_MONETARY category for monetary formatting information LC_COLLATE category for information affecting collating functions LC_CTYPE category for information affecting character class tests functions LC_TIME category for information affecting time conversions functions NULL null pointer constant struct lconv char* 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;

<math.h>
NeatInfo.com - by Jan Zumwalt

Pg 24 of 35
Copyright ©1995-2012

February 10, 2012

Common constants in #define M_E #define M_LOG2E #define M_LOG10E #define M_LN2 #define M_LN10 #define M_PI #define M_PI_2 #define M_PI_4 #define M_1_PI #define M_2_PI #define M_2_SQRTPI #define M_SQRT2 #define M_SQRT1_2

math.h 2.71828182845904523536028747135266250 1.44269504088896340735992468100189214 0.434294481903251827651128918916605082 0.693147180559945309417232121458176568 2.30258509299404568401799145468436421 3.14159265358979323846264338327950288 1.57079632679489661923132169163975144 0.785398163397448309615660845819875721 0.318309886183790671537767526745028724 0.636619772367581343075535053490057448 1.12837916709551257389615890312154517 1.41421356237309504880168872420969808 0.707106781186547524400844362104849039

/* /* /* /* /* /* /* /* /* /* /* /* /*

e */ log 2e */ log 10e */ log e2 */ log e10 */ pi */ pi/2 */ pi/4 */ 1/pi */ 2/pi */ 2/sqrt(pi) */ sqrt(2) */ 1/sqrt(2) */

#define MAXFLOAT ((float)3.40282346638528860e+38)

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_VAL double exp(double x); double log(double x); double log10(double x); double pow(double x, double y); double sqrt(double x); double ceil(double x); double floor(double x); double fabs(double x); double ldexp(double x, int n); double frexp(double x, int* exp); magnitude returned (with correct sign) on overflow error exponential of x natural logarithm of x base-10 logarithm of x x raised to power y square root of x smallest integer not less than x largest integer not greater than x absolute value of x x times 2 to the power n

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 modf(double x, double* ip); returns fractional part and assigns to *ip integral part of x, both with same sign as 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 sin(double x); sine of x double cos(double x); cosine of x double tan(double x); tangent of x double asin(double x); arc-sine of x double acos(double x); arc-cosine of x double atan(double x); arc-tangent of x double atan2(double y, double x); arc-tangent of y/x double sinh(double x); hyperbolic sine of x double cosh(double x); hyperbolic cosine of x double tanh(double x); hyperbolic tangent of x

<setjmp.h>
type of object holding context information Saves context information in env and returns zero. Subsequent call to longjmp with same env returns non-zero. void longjmp(jmp_buf env, int val); Restores context saved by most recent call to setjmp with specified env. Execution resumes as a second return from setjmp, with returned value val if specified value nonzero, or 1 otherwise. jmp_buf int setjmp(jmp_buf env);

<signal.h>
SIGABRT SIGFPE SIGILL SIGINT SIGSEGV NeatInfo.com - by Jan Zumwalt abnormal termination arithmetic error invalid execution (asynchronous) interactive attention illegal storage access

Pg 25 of 35
Copyright ©1995-2012

February 10, 2012

SIGTERM (asynchronous) termination request SIG_DFL specifies default signal handling SIG_ERR signal return value indicating error SIG_IGN specifies that signal should be ignored void (*signal(int sig, void (*handler)(int)))(int); Install handler for subsequent signal sig. If 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); Sends signal sig. Returns zero on success.

<stdarg.h>
va_list void va_start(va_list ap, lastarg); type of object holding context information Initialisation macro which must be called once before any unnamed argument is accessed. Stores context information in ap. lastarg is the last named parameter of the function. Yields value of the type (type) and value of the next unnamed argument. Termination macro which must be called once after argument processing and before exit from function.

type va_arg(va_list ap, type); void va_end(va_list ap);

<stddef.h>
NULL offsetof(stype, m) ptrdiff_t size_t Null pointer constant. Offset (in bytes) of member m from start of structure type stype. Type for objects declared to store result of subtracting pointers. Type for objects declared to store result of sizeof operator.

<stdio.h>
Size of buffer used by setbuf. Value used to indicate end-of-stream or to report an error. Maximum length required for array of characters to hold a filename. Maximum number of files which may be open simultaneously. Number of characters required for temporary filename generated by tmpnam. Null pointer constant. Value for origin argument to fseek specifying current file position. Value for origin argument to fseek specifying end of file. Value for origin argument to fseek specifying beginning of file. Minimum number of unique filenames generated by calls to tmpnam. Value for mode argument to setvbuf specifying full buffering. Value for mode argument to setvbuf specifying line buffering. Value for mode argument to setvbuf specifying no buffering. File pointer for standard input stream. Automatically opened when program execution begins. Stdout File pointer for standard output stream. Automatically opened when program execution begins. Stderr File pointer for standard error stream. Automatically opened when program execution begins. FILE Type of object holding information necessary to control a stream. fpos_t Type for objects declared to store file position information. size_t Type for objects declared to store result of sizeof operator. FILE* fopen(const char* filename, const char* mode); Opens file named filename and returns a stream, or NULL on failure. mode may be one of the following for text files: "r" text reading "w" text writing "a" text append "r+" text update (reading and writing) "w+" text update, discarding previous content (if any) "a+" text append, reading, and writing at end or one of those strings with b included (after the first character), for binary files. 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. NeatInfo.com - by Jan Zumwalt February 10, 2012 Pg 26 of 35 Copyright ©1995-2012 BUFSIZ EOF FILENAME_MAX FOPEN_MAX L_tmpnam NULL SEEK_CUR SEEK_END SEEK_SET TMP_MAX _IOFBF _IOLBF _IONBF Stdin

Flushes stream stream and returns zero on success or EOF on error. Effect undefined for input stream. fflush(NULL) flushes all output streams. Closes stream stream (after flushing, if output stream). Returns EOF on error, zero int fclose(FILE* stream); otherwise. 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. 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 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. 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 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. Conversion specifications consist of: % (optional) flag: left adjust + always sign space space if no sign 0 zero pad # Alternate form: for conversion character 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. (optional) minimum width: if specified as *, value taken from next argument (which must be int). (optional) . (separating width from precision): (optional) precision: for conversion character 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). (optional) length modifier: h l L short or unsigned short long or unsigned long long double

int fflush(FILE* stream);

conversion character: d,I o x,X u c s f e,E g,G p n NeatInfo.com - by Jan Zumwalt int argument, printed in signed decimal notation int argument, printed in unsigned octal notation int argument, printed in unsigned hexadecimal notation int argument, printed in unsigned decimal notation int argument, printed as single character char* argument double argument, printed with format [-]mmm.ddd double argument, printed with format [-]m.dddddd(e|E)(+|-)xx double argument void* argument, printed as pointer int* argument : the number of characters written to this point is written into argument

Pg 27 of 35
Copyright ©1995-2012

February 10, 2012

% no argument; prints % int printf(const char* format, ...); printf(f, ...) is equivalent to fprintf(stdout, f, ...) 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 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). 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. Each of the arguments following format must be a pointer. Format string may contain: blanks and tabs, which are ignored ordinary characters, which are expected to match next non-white-space of input conversion specifications, consisting of: % (optional) assignment suppression character "*" (optional) maximum field width (optional) target width indicator: H argument is pointer to short rather than int l argument is pointer to long rather than int, or double rather than float L argument is pointer to long double rather than float conversion character: decimal integer; int* parameter required integer; int* parameter required; decimal, octal or hex octal integer; int* parameter required unsigned decimal integer; unsigned int* parameter required hexadecimal integer; int* parameter required characters; char* parameter required; white-space is not skipped, and NUL-termination is not performed s string of non-white-space; char* parameter required; string is NUL-terminated e,f,g floating-point number; float* parameter required p pointer value; void* parameter required n chars read so far; int* parameter required [...] longest non-empty string from specified set; char* parameter required; string is NULterminated [^...] longest non-empty string not from specified set; char* parameter required; string is NULterminated % literal %; no assignment int scanf(const char* format, ...); scanf(f, ...) is equivalent to fscanf(stdin, f, ...) int sscanf(char* s, const char* format, ...); Like fscanf, but input read from string s. int fgetc(FILE* stream); Returns next character from (input) stream stream, or EOF on end-of-file or 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. Writes c, to stream stream. Returns c, or EOF on error. int fputc(int c, FILE* stream); char* fputs(const char* s, FILE* stream); Writes s, to (output) stream stream. Returns non-negative on success or EOF on error. Equivalent to fgetc except that it may be a macro. int getc(FILE* stream); 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-offile or error. Should not be used because of the potential for buffer overflow. NeatInfo.com - by Jan Zumwalt d I o u x c

Pg 28 of 35
Copyright ©1995-2012

February 10, 2012

Equivalent to fputc except that it may be a macro. putchar(c) is equivalent to putc(c, stdout). Writes s (excluding terminating NUL) and a newline to stdout. Returns non-negative on success, EOF on error. 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. 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.) 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 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. long ftell(FILE* stream); Returns current file position for stream stream, or -1 on error. void rewind(FILE* stream); Equivalent to fseek(stream, 0L, SEEK_SET); clearerr(stream). int fgetpos(FILE* stream, fpos_t* ptr); Stores current file position for stream stream in *ptr. 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. Clears end-of-file and error indicators for stream stream. void clearerr(FILE* stream); 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. void perror(const char* s); Prints s (if non-null) and strerror(errno) to standard error as would: fprintf(stderr, "%s: %s\n", (s != NULL ? s : ""), strerror(errno))

int putc(int c, FILE* stream); int putchar(int c); int puts(const char* s);

<stdlib.h>
EXIT_FAILURE EXIT_SUCCESS RAND_MAX NULL div_t int quot; int rem; ldiv_t long quot; long rem; size_t int abs(int n); long labs(long n); div_t div(int num, int denom); ldiv_t ldiv(long num, long denom); double atof(const char* s); Value for status argument to exit indicating failure. Value for status argument to exit indicating success. Maximum value returned by rand(). Null pointer constant. Return type of div(). Structure having members: quotient remainder Return type of ldiv(). Structure having members: quotient remainder Type for objects declared to store result of sizeof operator. Returns absolute value of n.

Returns quotient and remainder of num/denom. 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. 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. NeatInfo.com - by Jan Zumwalt

Pg 29 of 35
Copyright ©1995-2012

February 10, 2012

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. 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. Returns pointer to uninitialised newly-allocated space for an object of size size, or NULL void* malloc(size_t size); on error. 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 free(void* p); If p non-null, deallocates space to which it points. void abort(); Terminates program abnormally, by calling raise(SIGABRT). 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 implementationdependent manner. Zero or EXIT_SUCCESS indicates successful termination and EXIT_FAILURE indicates unsuccessful termination. Implementations may define other values. int atexit(void (*fcm)(void)); Registers fcn to be called when program terminates normally (or when main returns). Returns non-zero on failure. 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. char* getenv(const char* name); Returns string associated with 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)); 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 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 srand(unsigned int seed); Uses seed as seed for new sequence of pseudo-random numbers. Initial seed is 1.

<string.h>
NULL Null pointer constant. size_t Type for objects declared to store result of sizeof operator. char* strcpy(char* s, const char* ct); Copies ct to s including terminating NUL and returns s. 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* strcat(char* s, const char* ct); Concatenate ct to s and return s. 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 strcmp(const char* cs, const char* ct); Compares 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); Compares at most (the first) 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); Compares 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); Returns pointer to first occurrence of c in cs, or NULL if not 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. 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* 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. NeatInfo.com - by Jan Zumwalt

Pg 30 of 35
Copyright ©1995-2012

February 10, 2012

char* strstr(const char* cs, const char* ct); Returns pointer to first occurrence of ct within cs, or NULL if none is found. size_t strlen(const char* cs); Returns length of cs. char* strerror(int n); Returns pointer to implementation-defined message string corresponding with error n. 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. 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. 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 cs<ct, zero if cs==ct, positive value if cs>ct. 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. void* memset(void* s, int c, size_t n); Replaces each of the first n characters of s by c and returns s.

<time.h>
CLOCKS_PER_SEC The number of clock_t units per second. NULL Null pointer constant. clock_t An arithmetic type elapsed processor representing time. time_t An arithmetic type representing calendar time. struct tm Represents the components of calendar time: int tm_sec; seconds after the minute int tm_min; minutes after the hour int tm_hour; hours since midnight int tm_mday; day of the month int tm_mon; months since January int tm_year; years since 1900 int tm_wday; days since Sunday int tm_yday; days since January 1 int tm_isdst; Daylight Saving Time flag : is positive if DST is in effect, zero if not in effect, negative if information not known. Implementations may change field order and include additional fields. clock_t clock(void); Returns elapsed processor time used by program or -1 if not available. 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. double difftime(time_t time2, time_t time1); Returns the difference in seconds between time2 and time1. 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. char* asctime(const struct tm* tp); Returns the given time as a string of the form: Sun Jan 3 13:08:42 1988\n###BOT_TEXT### char* ctime(const time_t* tp); Returns string equivalent to calendar time tp converted to local time. Equivalent to: asctime(localtime(tp)) 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. 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. Formatting conversions (%c) are: A name of weekday A abbreviated name of weekday B name of month B abbreviated name of month C local date and time representation NeatInfo.com - by Jan Zumwalt

Pg 31 of 35
Copyright ©1995-2012

February 10, 2012

D H I J M M P S U W W X X Y Y Z % %

day of month [01-31] hour (24-hour clock) [00-23] hour (12-hour clock) [01-12] day of year [001-366] minute [00-59] month [01-12] local equivalent of "AM" or "PM" second [00-61] week number of year (Sunday as 1st day of week) [00-53] week number of year (Monday as 1st day of week) [00-53] weekday (Sunday as 0) [0-6] local time representation local date representation year with century year without century [00-99] name (if any) of time zone

Local time may differ from calendar time because of time zone.

NeatInfo.com - by Jan Zumwalt

Pg 32 of 35
Copyright ©1995-2012

February 10, 2012

Naming Conventions
Class specific
Class names start with lowercase 'c' ex: cDog Class varibles start with lowercase 'its' ex: itsBreed Objects created from a class start with a lowercase 'o'. Ex: oPooch

Generic Naming Conventions
Numaric varibles have the following prefix; 'ct' is for counters, ex: ctRow 'd' for dates, ex: dBirthday 'i' for integer, ex: iAge 'ui' for unsigned int, ex: uiAge 'f' for floating point ex: fStarDate 'l' long, ex: lAtoms 'n' is for misc data, ex: nLogo 't' for time, ex: tPayStart Character or string varibles start with lowercase 's'. ex: sName Pointer varibles start with a lowercase 'p'. Ex: pMyData Constants are all uppercase. ex: GRAVITY Function and method names start with lowercase 'm'. Ex: mDaysInMonth()

Definitions
variable = a name given to a value example: a= 34 / width type = the diffinition of a varible, it defines; a) it's size b) what infornation it can hold c) it's capabilities (what it can doe) class = collection of variable types used to define something. A class is not an actual thing, it is the instructions to create it. An object is created using the class as a template. A class also contains it's capabilities. In our example of a car it is capable of starting, stopping, turning, etc. example: if a car is a class then wheels, fuel, and engine would be types.
NeatInfo.com - by Jan Zumwalt

Pg 33 of 35
Copyright ©1995-2012

February 10, 2012

member variable = also called 'data members' are the varibles in a class. member function = also called 'methods' are the functions or routines in the class. encapsulation = The ability store a class's variables and capabilities as a single entity A 'Car' class would be used to make a 'Ford' object. example: the car's 'types' and 'capabilities' can be stored and used as a single item. object = An actual 'thing' created from a 'class' template.

Creating objects int vAge; cDog oPooch; psudo class code class <class name> { <access>: type <var name>; type <var name>; etc... <func name> (); };

Class Example class cDog { public: unsigned int unsigned int char fBark (); fSleep(); fEat(); };

itsFood; itsAge; itsBreed [50];

Once the class is defined we can create an object from it, in this case we create oPooch... Ex: cDog oPooch; To assign values to an object use <name.varible>... Ex: OPooch.itsAge = 6;

Access (visibility)
When a class is defined, its members are 'private' by default. That means other classes or programs can not change or access it. Using the keyword 'public' makes them available. Keeping as much of a class private as possible is a good thing. Usually you allow access to it by special functions called an accessor. You can also control access by the 'private' and 'public keyword. Any variables declared after the keyword have that keys access.
public: fEat(); unsigned int private: unsigned int char itsFood; itsAge; itsBreed [50];

NeatInfo.com - by Jan Zumwalt

Pg 34 of 35
Copyright ©1995-2012

February 10, 2012

In the above example, the fEat function and itsFood variable could be changed by another class or program but itsAge and itsBreed as well as anything else that followed could not be changed. small example
class cDog { public: fSetAge(); private unsigned int char fBark (); }; cDog oPooch;

itsAge; itsBreed [50];

fSetAge(int newage) { oPooch.itsAge = newage; fprint("Pooch's age is ", oPooch.itsAge, "/n/n") } int main() { oPooch.itsAge = 5; fSetAge(5); }

//won't work, varible is not public //works, function is public

NeatInfo.com - by Jan Zumwalt

Pg 35 of 35
Copyright ©1995-2012

February 10, 2012