Index


RISC World

Easy C++ Manual

Copyright © ProAction and APDL, 2001

ANSI functions

All C programs linked to the library STDClib have access to the full range of standard ANSI functions. EasyC is supplied with all 15 header files which declare these ANSI functions. The most useful of these are declared in the 5 header files listed below, and are described in detail in this chapter:

  ctype.h
  stdlib.h
  math.h
  string.h
  stdio.h

Many more ANSI functions are declared in the 10 header files listed below. All of these may be used from EasyC, but due to their more advanced nature they are not documented in this user guide. However, the syntax of these functions can be found by studying the header files.

  assert.h
  setjmp.h
  errno.h
  signal.h
  float.h
  stdarg.h
  limits.h
  stddef.h
  locale.h
  time.h

Further information about ANSI functions can be found in the Tutorial in the previous chapter, and in most good books on C programming. For the definitive text on the C programming language and descriptions of all ANSI functions you should refer to the IOC/IEC international standard called Programming languages - C (ref. ISO/IEC 9899).

Character Handling

The header <ctype.h> declares several functions useful for testing and mapping characters. In all cases the argument is an int, the value of which shall be representable as an unsigned char or shall equal the value of the macro EOF. If the argument has any other value the behaviour of the functions will be undefined.

The behaviour of these functions is affected by the current locale. those functions that have implementation-defined aspects only when not in the "C" locale are noted below.

The term printing character refers to a member of an implementation-defined set of characters, each of which occupies one printing position on a display device; the term control character refers to a member of an implementation-defined set of characters that are not printing characters.

Character testing functions

   Name    isalnum

   Syntax    int isalnum(int c);

   Description    Test for any character for which isalpha or isdigit is true.

   Returns    Nonzero (true) if and only if the argument c conforms to that in the description of the function.

   Name    isalpha

   Syntax    int isalpha(int c);

   Description    Test for any character for which isupper or islower is true, or any character that is one of an implementation-defined set of characters for which not of iscntrl , isdigit , ispunct , or isspace is true. In the "C" locale, isalpha returns true only for characters for which isupper or islower is true.

   Returns    Nonzero (true) if and only if the argument c conforms to that in the description of the function.

   Name    iscntrl

   Syntax    int iscntrl(int c);

   Description    Test for any control character.

   Returns    Nonzero (true) if and only if the argument c conforms to that in the description of the function.

   Name    isdigit

   Syntax    int isdigit(int c);

   Description    Test for any decimal-digit character.

   Returns    Nonzero (true) if and only if the argument c conforms to that in the description of the function.

   Name    isgraph

   Syntax    int isgraph(int c);

   Description    Test for any printing character except space (' ').

   Returns    Nonzero (true) if and only if the argument c conforms to that in the description of the function.

   Name    islower

   Syntax    int islower(int c);

   Description    Test for any character that is a lowercase letter or is one of an implementation-defined set of characters for which none of iscntrl , isdigit , ispunct , or isspace is true. In the "C" locale, islower returns true only for the characters defined as lowercase letters.

   Returns    Nonzero (true) if and only if the argument c conforms to that in the description of the function.

   Name    isprint

   Syntax    int isprint(int c);

   Description    Test for any printing character including space (' ').

   Returns    Nonzero (true) if and only if the argument c conforms to that in the description of the function.

   Name    ispunct

   Syntax    int ispunct(int c);

   Description    Test for any printing character that is neither space (' ') nor a character for which isalnum is true.

   Returns    Non-zero (true) if and only if the argument c conforms to to that in the description of the function.

   Name    isspace

   Syntax    int isspace(int c);

   Description    Test for any character that is a standard white-space character or is one of an implementation-defined set of characters for which isalnum is false. The standard white-space characters are the following: space ( ' ' ), form feed ( '\f' ), new-line ( '\n' ), carriage return ( '\r' ), horizontal tab ( '\t' ), and vertical tab ( '\v' ). in the "C" locale, isspace returns true only for the standard white-space characters.

   Returns    Non-zero (true) if and only if the argument c conforms to to that in the description of the function.

   Name    isupper

   Syntax    int isupper(int c);

   Description    Test for any character that is an uppercase letter or is one of an implementation-defined set of characters for which none of iscntrl , isdigit , ispunct , or isspace is true. In the "C" locale, isupper returns true only for the characters defined as uppercase letters.

   Returns    Non-zero (true) if and only if the argument c conforms to to that in the description of the function.

   Name    isxdigit

   Syntax    int isxdigit(int c);

   Description    Test for any hexadecimal-digit character.

   Returns    Non-zero (true) if and only if the argument c conforms to to that in the description of the function.

    

Character case mapping functions

   Name    tolower

   Syntax    int tolower(int c);

   Description    Convert an uppercase letter to the corresponding lowercase letter.

   Returns    If the argument is a character for which isupper is true and there is a corresponding character for which islower is true, the tolower function returns the corresponding character; otherwise, the argument is returned unchanged.

   Name    toupper

   Syntax    int toupper(int c);

   Description    Convert a lowercase letter to the corresponding uppercase letter.

   Returns    If the argument is a character for which islower is true and there is a corresponding character for which isupper is true, the toupper function returns the corresponding character; otherwise, the argument is returned unchanged.

Mathematics <math.h>

The header <math.h> declares several mathematical functions and defines one macro. The functions take double arguments and return double values.

The macro defined is HUGE_VAL which expands to a positive double expression.

For all functions, a domain error occurs if an input argument is outside the domain over which the mathematical input is defined. The description of each function lists any required domain errors; an implementation may define additional domain errors, provided that such errors are consistent with the mathematical definition of the function. On a domain error, the function returns and implementation-defined value; the value of the macro EDOM is stored in errno .

Similarly, a range error occurs if the result of the function cannot be represented as a double value. If the result overflows (the magnitude of the result is so large that it cannot be represented in an object of the specified type), the function returns the value of the macro HUGE_VAL with the same sign (except for the tan function) as the correct value of the function; the value of the macro ERANGE is stored in errno . If the result undeflows (the magnitude of the result is so small that it cannot be represented in an object of the specified type), the function returns zero; whether the integer expression errno acquires the value of the macro ERANGE is implementation-defined.

Trigonometric functions

   Name    acos

   Syntax    double acos(double x);

   Description    Compute the principal value of the arc cosine of x . A domain error occurs for arguments not in the range [-1, +1].

   Returns    The arc cosine in the range [0, p] radians.

   Name    asin

   Syntax    double asin(double x);

   Description    Compute the principal value of the arc sine of x . A domain error occurs for arguments not in the range [-1, +1].

   Returns    The arc sine in the range [-p/2, +p/2] radians.

   Name    atan

   Syntax    double atan(double x);

   Description    Compute the principal value of the arc tangent of x .

   Returns    The arc tangent in the range [-p/2, +p/2] radians.

   Name    atan2

   Syntax    double atan2(double y, double x);

   Description    Compute the principal value of the arc tangent of y/x , using the signs of both arguments to determine the quadrant of the return value. A domain error occurs if both arguments are zero.

   Returns    The arc tangent of y/x in the range [-p, +p] radians.

   Name    cos

   Syntax    double cos(double x);

   Description    Compute the cosine of x (measured in radians).

   Returns    The cosine value.   

   Name    sin

   Syntax    double sin(double x);

   Description    Compute the sine of x (measured in radians).

   Returns    The sine value.

   Name    tan

   Syntax    double tan(double x);

   Description    Compute the tangent of x (measured in radians).

   Returns    The tangent value.   

Hyperbolic functions

   Name    cosh

   Syntax    double cosh(double x);

   Description    Compute the hyperbolic cosine of x . A range error occurs if the magnitude of x is too large.

   Returns    The hyperbolic cosine value.

   Name    sinh

   Syntax    double sinh(double x);

   Description    Compute the hyperbolic sine of x . A range error occurs if the magnitude of x is too large.

   Returns    The hyperbolic sine value.

   Name    tanh

   Syntax    double tanh(double x);

   Description    Computes the hyperbolic tangent of x .

   Returns    The hyperbolic tangent value.

Exponential and logarithmic functions

   Name    exp

   Syntax    double exp(double x);

   Description    Compute the exponential function of x . A range error occurs if the magnitude of x is too large.

   Returns    The exponential value.

   Name    frexp

   Syntax    double frexp(double value, int *exp);

   Description    Break a floating-point number into a normalised fraction and an integral power of 2. It stores the integer in the int object pointed to by exp .

   Returns    The value x , such that x is a double with magnitude in the interval [1/2, 1] or zero, and value equals x times 2 raised to the power *exp . If value is zero, both parts of the result are zero.

   Name    ldexp

   Syntax    double ldexp(double x, int exp);

   Description    Multiply a floating-point number by an integral of power 2. A range error may occur.

   Returns    The value of x times 2 raised to the power exp .   

   Name    log

   Syntax    double log(double x);

   Description    Compute the natural logarithm of x . A domain error occurs if the argument is negative. A range error occurs if the argument is zero.

   Returns    The natural logarithm.

   Name    log10

   Syntax    double log10(double x);

   Description    Compute the base-ten logarithm of x . A domain error occurs if the argument is negative. A range error occurs if the argument is zero.

   Returns    The base-ten logarithm.

   Name    modf

   Syntax    double modf(double value, double *iptr);

   Description    Break the argument value into integral and fractional parts, each of which has the same sign as the argument. It stores the integral part as a double in the object pointed to by iptr .

   Returns    The signed fractional part of value .   

Power functions

   Name    pow

   Syntax    double pow(double x, double y);

   Description    Compute x raised to the power y . A domain error occurs if x is negative and y is not an integral value. A domain error occurs if the result cannot be represented when x is zero and y is less than or equal to zero. A range error may occur.

   Returns    The value of x raised to the power y .

   Name    sqrt

   Syntax    double sqrt(double x);

   Description    Compute the non-negative square root of x .

   Returns    The value of the square root.

Miscellaneous functions

   Name    ceil

   Syntax    double ceil(double x);

   Description    Compute the smallest integral value not less than x .

   Returns    The smallest integral not less than x , expressed as a double.

   Name    fabs

   Syntax    double fabs(double x);

   Description    Compute the absolute value of a floating-point number x .

   Returns    The absolute value of x .

   Name    floor

   Syntax    double floor(double x);

   Description    Compute the largest integral value not greater than x .

   Returns    The largest integral value not greater than x , expressed as a double.

   Name    fmod

   Syntax    double fmod(double x, double y);

   Description    Computes the floating-point remainder of x/y .

   Returns    The value x - i * y , for some integer i such that, if y is nonzero, the result has the same sign as x and magnitude less than the magnitude of y . If y is zero, whether a domain error occurs or the fmod function returns zero is implementation-defined.

APDL and ProAction

 Index