puts

Defined in header <stdio.h> int puts( const char *str ); Writes character string str and a newline to stdout. Parameters str - character string to be written Return value non-negative number on success or EOF otherwise. Example puts() with error checking. #include <stdio.h> #include <stdlib.h> int main(void) { int ret_code = puts("Hello World"); if ((ret_code == EOF) && (ferror(stdout))) /* test whether EOF was reached */

putchar

Defined in header <stdio.h> int putchar( int ch ); Writes a character ch to stdout. Internally, the character is converted to unsigned char just before being written. Equivalent to putc(ch, stdout). Parameters ch - character to be written Return value On success, returns the written character. On failure, returns EOF and sets the error indicator (see ferror()) on stdout. Example putchar with error checking. #include <stdio.h> #include <stdlib.h>

ptrdiff_t

Defined in header <stddef.h> typedef /*implementation-defined*/ ptrdiff_t; ptrdiff_t is the signed integer type of the result of subtracting two pointers. Notes ptrdiff_t is used for pointer arithmetic and array indexing, if negative values are possible. Programs that use other types, such as int, may fail on, e.g. 64-bit systems when the index exceeds INT_MAX or if it relies on 32-bit modular arithmetic. Only pointers to elements of the same array (including the pointer

Pseudo-random number generation

Defined in header <stdlib.h> rand generates a pseudo-random number (function) srand seeds pseudo-random number generator (function) RAND_MAX maximum possible value generated by rand() (macro constant) References C11 standard (ISO/IEC 9899:2011): 7.22.2 Pseudo-random sequence generation functions (p: 346-347) C99 standard (ISO/IEC 9899:1999): 7.20.2 Pseudo-random sequence generation functions (p: 312-313) C89/C90 standard (ISO/IEC 9899:1990): 4.10.2 Pseudo-ra

Program support utilities

Program termination The following functions manage program termination and resource cleanup. Defined in header <stdlib.h> abort causes abnormal program termination (without cleaning up) (function) exit causes normal program termination with cleaning up (function) quick_exit (C11) causes normal program termination without completely cleaning up (function) _Exit (C99) causes normal program termination without cleaning up (function) atexit registers a functi

printf

Defined in header <stdio.h> (1) ​int printf( const char *format, ... );​ (until C99) ​int printf( const char *restrict format, ... );​ (since C99) (2) int fprintf( FILE *stream, const char *format, ... ); (until C99) int fprintf( FILE *restrict stream, const char *restrict format, ... ); (since C99) (3) int sprintf( char *buffer, const char *format, ... ); (until C99) int sprintf( char *restrict buffer, const char *restrict format, ... ); (since C

Preprocessor

The preprocessor is executed at translation phase 4, before the compilation. The result of preprocessing is single file which is then passed to the actual compiler. Directives The preprocessing directives control the behavior of the preprocessor. Each directive occupies one line and has the following format: # character preprocessing instruction (one of define, undef, include, if, ifdef, ifndef, else, elif, endif, line, error, pragma) [1] arguments (depends on the instruction) line bre

pow

Defined in header <math.h> float powf( float base, float exponent ); (1) (since C99) double pow( double base, double exponent ); (2) long double powl( long double base, long double exponent ); (3) (since C99) Defined in header <tgmath.h> #define pow( base, exponent ) (4) (since C99) 1-3) Computes the value of base raised to the power exponent. 4) Type-generic macro: If any argument has type long double, powl is called. Otherwise, if any argu

Pointer declaration

Pointer is a type of an object that refers to a function or an object of another type, possibly adding qualifiers. Pointer may also refer to nothing, which is indicated by the special null pointer value. Syntax In the declaration grammar of a pointer declaration, the type-specifier sequence designates the pointed-to type (which may be function or object type and may be incomplete), and the declarator has the form: * qualifiers(optional) declarator (1) where declarator may be the iden

Phases of translation

The C source file is processed by the compiler as if the following phases take place, in this exact order. Actual implementation may combine these actions or process them differently as long as the behavior is the same. Phase 1 1) The individual bytes of the source code file (which is generally a text file in some multibyte encoding such as UTF-8) are mapped, in implementation defined manner, to the characters of the source character set. In particular, OS-dependent end-of-line indicators a