{"id":412,"date":"2009-11-20T11:44:27","date_gmt":"2009-11-20T11:44:27","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=412"},"modified":"2009-11-20T11:44:27","modified_gmt":"2009-11-20T11:44:27","slug":"conditions-true-or-false","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2009\/11\/20\/conditions-true-or-false\/","title":{"rendered":"Conditions &#8211; true or false"},"content":{"rendered":"<p>When you want to do a test against true or false with a integer value.  Basically 0 is false and anything else is true, as demonstrated below.<\/p>\n<pre lang=\"cpp\">\r\n#include <stdlib.h>\r\n#include <iostream>\r\n\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n  for (int i = -10; i < 10; i++)\r\n  {\r\n      if (i) \r\n\t  cout << \"true \" << i << endl;\r\n      else\r\n\t  cout << \"false \" << i << endl;\r\n  }\r\n}\r\n<\/pre>\n<p>and the output of this is, the true\/false values is after the if statement.<\/p>\n<pre lang=\"bash\">\r\ntrue -10\r\ntrue -9\r\ntrue -8\r\ntrue -7\r\ntrue -6\r\ntrue -5\r\ntrue -4\r\ntrue -3\r\ntrue -2\r\ntrue -1\r\nfalse 0\r\ntrue 1\r\ntrue 2\r\ntrue 3\r\ntrue 4\r\ntrue 5\r\ntrue 6\r\ntrue 7\r\ntrue 8\r\ntrue 9\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When you want to do a test against true or false with a integer value. Basically 0 is false and anything else is true, as demonstrated below. #include #include using namespace std; int main() { for (int i = -10; i < 10; i++) { if (i) cout\n<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-412","post","type-post","status-publish","format-standard","hentry","category-c_and_cpp"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":1,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/412\/revisions"}],"predecessor-version":[{"id":413,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/412\/revisions\/413"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}