stddef.h in C
The file header named stddef.h in C Library defines various types of variables and macros. Many of these definitions are also present in other headers.
The variables are defined in stddef.h
The following lists some types of variables defined in stddef.h in Library C:
Description variable ptrdiff_tThis is a signed integer type and is the result of subtraction of two pointers
size_tThis is an unsigned integer type and the result of the sizeof keyword
wchar_tThis is an integer type, the size of a large character constant (wide char)
Macros are defined in stddef.h
The table below lists some macros defined in stddef.h in Library C:
Macro Description NULLThis macro is the value of a null pointer constant
offsetof (type, member-designator)These results are in an integer constant of type size_t which is the offset (byte unit) of a structure member from the beginning of that structure. Members are provided by the member-designator parameter, and the name of the structure provided by type
1. Macro NULL () in C
The NULL macro in Library C is the value of a null pointer constant. It can be defined as ((void *) 0), 0 or 0L depending on the Compiler.
Macro declaration NULL () in C
The following may be the declaration for NULL Macro depending on the compiler.
#define NULL (( char *) 0 ) ho ặ c #define NULL 0L ho ặ c #define NULL 0
Parameters
This macro does not receive any parameters
Returns the value
This macro does not return any values
For example
The following C program illustrates how to use NULL Macro.
#include #include int main () { FILE * fp ; fp = fopen ( "nofile.txt" , "r" ); if ( fp == NULL ) { printf ( "Khong the mo nofile.txt !!!n" ); } return ( 0 ); }
Assuming we want to open a non-existent nofile.txt, when compiling and running the above C program will result:
2. The offsetof macro () in C
The offsetof (type, member-designator) macro in standard C Library results in an integer constant of type size_t which is the offset (byte unit) of a structure member from the beginning of that structure. Members are provided by member-designator, and the name of the structure provided by type.
Offof () Macro declaration in C
Below is the declaration for offsetof () Macro.
offsetof ( type , member - designator )
Parameters
type - This is the type of class where member-designator is a valid identifier.
member-designator - This is the member name of the class type.
Returns the value
This macro returns the value of type size_t which is the member offset in the type.
For example
The following C program illustrates the use of offsetof () Macro.
#include #include struct student { char name [ 50 ]; char school [ 50 ]; int rollno ; }; int main () { printf ( "name offset = %d byte trong student struct.n" , offsetof ( struct student , name )); printf ( "class offset = %d byte trong student struct.n" , offsetof ( struct student , school )); printf ( "rollno offset = %d byte trong student struct.n" , offsetof ( struct student , rollno )); return ( 0 ); }
Compiling and running the above C program will result:
According to Tutorialspoint
Last lesson: stdarg.h in C
Next lesson: stdio.h in C
You should read it
May be interested
- Check out the 'buffalo' Pokémon in Pokémon Goeach type of pokemon has hp, cp, ability to attack and endure differently. based on these indicators, players can determine as well as choosing the most powerful pokemon for their offensive tactics.
- Sitting home can also locate Pokemon around, do you believe it?the tightening of the niantic developers' rules to prevent players from abusing the support tools also brings annoyance, such as those who have no conditions to move much, go away, it is hard to know. get the location of the pokemon around the area they live in
- 5 undeniable benefits when playing Pokemon Goget to know many new people, breathe fresh air, relieve stress, increase concentration thanks to going out for a walk .... are compelling reasons to force you to try pokemon go now .
- Want to earn the fastest Pokécoins in Pokémon Go? So don't miss this article!pokécoins in pokémon go play the role of buying items in the store. the more coins you earn, the more likely you are to buy more items. to earn pokécoins, players will have to complete certain tasks or buy real money.
- Pokémon systems when fighting in Pokémon Goeach pokémon system in pokémon go has different strengths, along with a specific weakness. this type of pokémon will have the power to attack the other pokémon, but can defeat the other pokémon. if you know the characteristics of each type, it will be easier to choose which pokémon to battle.
- The terms you need to know when playing Pokémon Gopokémon go is the most prominent name in recent days. this game of capturing and training virtual animals has created a relatively new way of playing, as players have to constantly move to catch pokémon. during the process of joining pokémon go, you will encounter and use a lot of important terms. so what do they mean?
- How to play Pokemon GO on Windows computersrecently, pokemon go has become a popular game, attracting thousands of gamers around the world. in previous posts network administrator has guided you on how to play pokemon go on android devices and ios devices. in the article below, network administrator will guide you how to play pokemon go on windows computers using bluestacks emulator software.
- How to become a good Pokémon Go hunter?with a new way of playing, pokémon go has created a new phenomenon in the game village around the world. players will have to go around and find pokémon for themselves. so how to quickly catch pokémon and in large numbers?
- Things to know to upgrade Pokémon in Pokémon Gothe whirlwind pokémon go has spread its power right on the first day of its release. everyone rushed to the street to find a pokémon for themselves. therefore, in order to become a pokémon hunter, you need to master the basics of participating in pokémon go battlefield.
- List of medals received in Pokemon Goin addition to getting items when leveling up, gamers who join pokemon go also have the opportunity to receive their proud achievements.