> Online tutorial

sizeof()

Returns the size, in bytes, of the given expression or type (as type size_t).

 Syntax:

 sizeof <expression>
   sizeof ( <type> )

 Example:

  memset(buff, 0, sizeof(buff));
  nitems = sizeof(table) / sizeof(table[0]);


abort       
      
 Abnormally terminates a process

 Declaration

void abort(void);

 Remarks:

abort writes a termination message on stderr ("Abnormal program
termination"), then aborts the program by a call to _exit with exit code 3.

 Return Value:

Returns exit code 3 to the parent process or to DOS




 Example:

 #include <stdio.h>
 #include <stdlib.h>

 int main(void)
 {
   printf("Calling abort()\n");
   abort();
   return 0; /* This is never reached */
 }

fmod()

 Calculates x modulo y, the remainder of x/y

 Declaration:

double fmod(double x, double y);
 long double fmod(long double (x), long double (y));

 Remarks:

fmod and fmodl calculate x modulo y. This is defined as the remainder f,
where

  x = (ay + f) for some integer a

and

  0 < f < y.

 Return Value:


 Where  x = ay + f  and  0 < f < y,
    fmod and fmodl return the remainder f.
 Where  y = 0, fmod and fmodl return 0.

 Example:

 #include <stdio.h>
 #include <math.h>

 int main(void)
 {
    double x = 5.0, y = 2.0;
    double result;

    result = fmod(x,y);
    printf("The remainder of (%lf / %lf) is %lf\n", x, y, result);
    return 0;
 }

modf

 modf splits double into integer and fraction parts
 modfl splits long double into integer and fraction parts

 Declaration:

double modf(double x, double *ipart);
 long double modfl(long double (x), long double *(ipart));

 Remarks:

 modf breaks the double x into two parts: the integer and the fraction. It
stores the integer in ipart and returns the fraction.

 modfl is the long double version of modf.

 Return Value:


Both functions return the fractional part of x.

 Example:

 #include <math.h>
 #include <stdio.h>

 int main(void)
 {
    double fraction, integer;
    double number = 100000.567;

    fraction = modf(number, &integer);
    printf("The whole and fractional parts of %lf are %lf and %lf\n",
           number, integer, fraction);
    return 0;
 }

Atoi 

Macro that converts string to integer

Declaration:

int atoi(const char *s);

Remarks:

atoi converts a string pointed to by s to int. atoi recognizes (in the following order) an optional string of tabs and spaces an optional sign a string of digits The characters must match this format: [ws] [sn] [ddd] In atoi, the first unrecognized character ends the conversion. There are no provisions for overflow in atoi (results are undefined).

Return Value:

On success, returns the converted value of the input string. If the string can't be converted, returns 0.

Example:
#include<stdlib.h>
 #include <stdio.h>
int main(void)
{
int n;
char *str = "12345.67";
n = atoi(str);
printf("string = %s integer = %d\n", str, n); 
}