C Data Types
In C, data types refer to a comprehensive system for declaring variables and functions of various sorts. The type of a variable dictates how much storage space it takes up and how the stored bit pattern is interpreted.
The types in C can be divided into the following categories:
- Types of Basics: They are arithmetic types that are divided into two categories: integer types and floating-point types.
- Enumerated types: These are arithmetic types that are used throughout the programme to define variables that can only assign discrete integer values.
- The type void: The type specifier void denotes the absence of a value.
- Derived Types: Pointer kinds, Array types, Structure types, Union types, and Function types are some of them.
The aggregate types are a combination of array types and structure types. The type of a function's return value is determined by its type. The basic types will be covered in the following section, while further types will be presented in subsequent chapters.
The void type denotes the absence of a value. It's used in three different scenarios:
- Functions that return void: In C, there are a number of functions that return void, or no value at all. The return type of a function with no return value is void. void exit (int status), for example.
- As void parameters to functions: In C, there are a number of functions that don't take any parameters. A void can be passed to a function that has no parameters. Int rand(void), for example.
- void pointers: The address of an object is represented by a pointer of type void *, but not its type. For example, the void *malloc( size t size ); memory allocation function returns a pointer to void that can be cast to any data type.