Warning: Undefined array key 1 in /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php on line 505

Warning: Undefined array key 2 in /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php on line 505

Warning: Cannot modify header information - headers already sent by (output started at /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php:505) in /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php on line 557

Warning: Cannot modify header information - headers already sent by (output started at /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php:505) in /home/yogindar/www/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1930

Warning: Cannot modify header information - headers already sent by (output started at /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php:505) in /home/yogindar/www/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1930

Warning: Cannot modify header information - headers already sent by (output started at /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php:505) in /home/yogindar/www/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1930

Warning: Cannot modify header information - headers already sent by (output started at /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php:505) in /home/yogindar/www/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1930

Warning: Cannot modify header information - headers already sent by (output started at /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php:505) in /home/yogindar/www/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1930

Warning: Cannot modify header information - headers already sent by (output started at /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php:505) in /home/yogindar/www/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1930

Warning: Cannot modify header information - headers already sent by (output started at /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php:505) in /home/yogindar/www/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1930

Warning: Cannot modify header information - headers already sent by (output started at /home/yogindar/www/blog/wp-content/plugins/visitors-online/visitors-online.php:505) in /home/yogindar/www/blog/wp-includes/rest-api/class-wp-rest-server.php on line 1930
{"id":2154,"date":"2020-08-22T13:25:43","date_gmt":"2020-08-22T13:25:43","guid":{"rendered":"http:\/\/www.yogindar.com\/news\/?p=2154"},"modified":"2020-08-22T13:25:43","modified_gmt":"2020-08-22T13:25:43","slug":"assertions-in-c-c","status":"publish","type":"post","link":"http:\/\/blog.yogindar.org\/?p=2154","title":{"rendered":"Assertions in C\/C++"},"content":{"rendered":"

Assertions help programmers to test conditions and abort the programs. Mainly used when the code cannot execute further if the condition is not met.<\/p>\n

The syntax of assert is<\/b><\/p>\n

void assert(scalar expression);<\/p><\/blockquote>\n

Need to include the following header which defined the
\nassert macro.<\/p>\n

#include <assert.h><\/p><\/blockquote>\n

Assert prints the error message to standard error
\nand terminates the program by calling abort(3).<\/p>\n

code<\/p>\n

assert( val == 0)<\/p><\/blockquote>\n

output<\/p>\n

\n
prog: some_file.c:16: some_func: Assertion `val == 0' failed.<\/pre>\n<\/blockquote>\n

Assertions can be turned off by defining NDEBUG macro. Adding NDEBUG will cause assert not to generate any code to print error and abort.<\/p>\n

Recommendation is to not use the NDEBUG macro if using assert to detect error conditions as software may behave non-deterministically.<\/p>\n

Source: Assertions in C\/C++ – GeeksforGeeks<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"

Assertions help programmers to test conditions and abort the programs. Mainly used when the code cannot execute further if the condition is not met. The syntax of assert is void assert(scalar expression); Need to include the following header which defined the assert macro. #include <assert.h> Assert prints the error message to standard error and terminates […]<\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1337],"tags":[1557,1333],"class_list":["post-2154","post","type-post","status-publish","format-standard","hentry","category-my-article","tag-assert","tag-programming-2"],"_links":{"self":[{"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/posts\/2154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2154"}],"version-history":[{"count":1,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/posts\/2154\/revisions"}],"predecessor-version":[{"id":2155,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=\/wp\/v2\/posts\/2154\/revisions\/2155"}],"wp:attachment":[{"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2154"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.yogindar.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}