C Keywords and Functions
C Keywords and Functions
double A data type that is usually 64 bits long which can store fractional numbers
float A data type that is usually 32 bits long which can store fractional numbers
int A data type that is usually 32 bits long which can store whole numbers
long Ensures that an integer is at least 32 bits long (use long long to ensure 64 bits)
sizeof An operator that returns the amount of memory occupied by a variable or data type
static Specifies that a variable in a function keeps its value after the function ends
unsigned Specifies that an int or char should only represent positive values which allows for storing n
as large
void Indicates a function that does not return a value or specifies a pointer to a data with an uns
C stdio Functions
The <stdio.h> header provides a variety of functions for input, output and file handling.
Function Description
feof() Returns a true value when the position indicator has reached the end of the file
fgetc() Returns the ASCII value of a character in a file and advances the position indicator
fgets() Reads a line from a file and advances the position indicator
fopen() Opens a file and returns a file pointer for use in file handling functions
fputc() Writes a character into a file and advances the position indicator
fputs() Writes a string into a file and advances the position indicator
fread() Reads data from a file and writes it into a block of memory
fscanf() Reads formatted data from a file and writes it into a number of memory locations
getchar() Reads one character of user input and returns its ASCII value
sscanf() Reads a formatted string from a char array and writes it into a number of memory locations
C stdlib Functions
The <stdlib.h> header (standard library) provides a variety of commonly used functions.
Function Description
atol() Return a long int value from a string representation of a whole number
atoll() Return a long long int value from a string representation of a whole number
❮ PreviousNext ❯
C string Functions
The <string.h> library has many functions that allow you to perform tasks on strings.
Function Description
memcmp() Compares two blocks of memory to determine which one represents a larger numeric value
memmove() Copies data from one block of memory to another accounting for the possibility that the blo
overlap
memset() Sets all of the bytes in a block of memory to the same value
strcmp() Compares the ASCII values of characters in two strings to determine which string has a highe
strcoll() Compares the locale-based values of characters in two strings to determine which string has
strcpy() Copies the characters of a string into the memory of another string
strcspn() Returns the length of a string up to the first occurrence of one of the specified characters
strncat() Appends a number of characters from a string to the end of another string
strncmp() Compares the ASCII values of a specified number of characters in two strings to determine w
higher value
strncpy() Copies a number of characters from one string into the memory of another string
strpbrk() Returns a pointer to the first position in a string which contains one of the specified characte
strspn() Returns the length of a string up to the first character which is not one of the specified chara
strxfrm() Convert characters in a string from ASCII encoding to the encoding of the current locale
❮ PreviousNext ❯
C Math Functions
The <math.h> library has many functions that allow you to perform mathematical tasks on numbers.
Function Description
atan(x) Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians
atan2(y, x) Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordin
copysign(x, y) Returns the first floating point x with the sign of the second floating point y
frexp(x, y) With x expressed as m*2n, returns the value of m (a value between 0.5 and 1.0) and writes th
memory at the pointer y
lgamma(x) Returns the logarithm of the absolute value of the gamma function at x
llrint(x) Rounds x to a nearby integer and returns the result as a long long integer
llround(x) Rounds x to the nearest integer and returns the result as a long long integer
lrint(x) Rounds x to a nearby integer and returns the result as a long integer
lround(x) Rounds x to the nearest integer and returns the result as a long integer
modf(x, y) Returns the decimal part of x and writes the integer part to the memory at the pointer y
remquo(x, y, z) Calculates x/y rounded to the nearest integer, writes the result to the memory at the pointer
remainder.
❮ PreviousNext ❯
C ctype Functions
The <ctype.h> header provides many functions for classifying and modifying characters.
Function Description