assert.h in C
assert.h in C
The file header named assert.h from Library C provides a macro called assert that can be used to test an assumption made by the program and print a diagnostic message to find the error if this assumption is false .
The macro is predefined assert this reference to another macro is NDEBUG which is not part of. If NDEBUG is defined as a macro name in the source file, where it is included, assert is defined as follows:
#define assert ( ignore ) (( void ) 0 )
The macros are defined in assert.h
In assert.h only define the following macro:
void assert (int expression): This is really a macro and not a function. This macro is used to add diagnostics to find errors in the C program.
Assert macro () in C
The assert () function in C
Macro void assert (int bieu-thuc) in Standard C Library allows detection diagnostic information to be written to standard error file (Standard Error File). In other words, it can be used to add diagnostic messages to find errors in C programming.
Declare assert () function in C
Below is the declaration for the assert () Macro in the standard C Library.
void assert ( int bieu - thuc );
Parameters
bieu-thuc: This can be a variable or any C expression. If the command evaluates to TRUE, then assert () does nothing. If the method evaluates to false, then assert () displays an error message on stderr and stops executing the program.
Return value
This macro does not return any values.
For example
The following C program illustrates the use of assert () macros in Library C:
#include #include int main () { int a ; char str [ 50 ]; printf ( "Nhap mot gia tri nguyen: n" ); scanf ( "%d" , & a ); assert ( a >= 10 ); printf ( "Gia tri nguyen vua nhap la %dn" , a ); printf ( "Nhap mot chuoi: " ); scanf ( "%s" , & str ); assert ( str != NULL ); printf ( "Chuoi vua nhap la: %sn" , str ); return ( 0 ); }
Compile and run the above program to see the results:
According to Tutorialspoint
Previous post: Command line parameter in C
Next story: ctype.h in C
You should read it
- Firefox 14 prohibits Flash by default
- What is a macro in Excel? How to create and run a Macro in Excel
- stdarg.h in C
- The easiest way to Use Macros in Excel
- string.h in C
- How to fix Office error 'The function you are attempting to run contains macros'
- MS Excel 2003 - Lesson 8: Excel Macro - Automate complex tasks
- stddef.h in C
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.