Previous Section
 < Free Open Study > 
Next Section


C.7 The Header File cstdlib

abs (i)

  • Argument:

An int expression i

  • Function return value:

An int value that is the absolute value of i

atof (str)

  • Argument:

A C string (null-terminated char array) str representing a floating point number, possibly preceded by whitespace characters and a '+' or '-'

  • Function return value:

A double value that is the floating-point equivalent of the characters in str

  • Note:

Conversion stops at the first character in str that is inappropriate for a floating-point number. If no appropriate characters were found, the return value is system dependent.

atoi(str)

  • Argument:

A C string (null-terminated char array) str representing an integer number, possibly preceded by whitespace characters and a '+' or '-'

  • Function return value:

An int value that is the integer equivalent of the characters in str

  • Note:

Conversion stops at the first character in str that is inappropriate for an integer number. If no appropriate characters were found, the return value is system dependent.

atol(str)

  • Argument:

A C string (null-terminated char array) str representing a long integer, possibly preceded by whitespace characters and a '+' or '-'

  • Function return value:

A long value that is the long integer equivalent of the characters in str

  • Note:

Conversion stops at the first character in str that is inappropriate for a long integer number. If no appropriate characters were found, the return value is system dependent.

exit(exitStatus)

  • Argument:

An int expression exitStatus

  • Effect:

Program execution terminates immediately with all files properly closed

  • Function return value:

None (a void function)

  • Note:

By convention, exitStatus is 0 to indicate normal program completion and is nonzero to indicate an abnormal termination.

labs(i)

  • Argument:

A long expression i

  • Function return value:

A long value that is the absolute value of i

rand()

  • Argument:

None

  • Function return value:

A random int value in the range 0 through RAND_MAX, a constant defined in cstdlib (RAND_MAX is usually the same as INT_MAX)

  • Note:

See srand below.

srand(seed)

  • Argument:

An int expression seed, where seed 0

  • Effect:

Using seed, the random number generator is initialized in preparation for subsequent calls to the rand function.

  • Function return value:

None (a void function)

  • Note:

If srand is not called before the first call to rand, a seed value of 1 is assumed.

system(str)

  • Argument:

A C string (null-terminated char array) str representing an operating system command, exactly as it would be typed by a user on the operating system command line

  • Effect:

The operating system command represented by str is executed.

  • Function return value:

An int value that is system dependent

  • Note:

Programmers often ignore the function return value, using the syntax of a void function call rather than a value-returning function call.



Previous Section
 < Free Open Study > 
Next Section
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)