{"id":139,"date":"2009-07-24T12:19:14","date_gmt":"2009-07-24T11:19:14","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=139"},"modified":"2009-07-24T12:19:36","modified_gmt":"2009-07-24T11:19:36","slug":"define-the-marco-that-can-save-time","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2009\/07\/24\/define-the-marco-that-can-save-time\/","title":{"rendered":"Define &#8211; the marco that can save time"},"content":{"rendered":"<p>The define part of the c\/c++ language is able to save on coding time.  The define is only really good for a one line of code that a function would be far to much of a over kill.<\/p>\n<p>Here are three examples of the define, <\/p>\n<pre lang=\"cpp\">\r\n#define MAXVALUE 20\r\n<\/pre>\n<p>this will allow for a hard coded value to be used within the coding<\/p>\n<pre lang=\"cpp\">\r\n#define PrintHello cout << \"Hello\" << endl;\r\n<\/pre>\n<p>this will print hello when you call the marco as<\/p>\n<pre lang=\"cpp\">\r\nvoid main()\r\n{\r\n       PrintHello;\r\n}\r\n<\/pre>\n<p>and last is passing parameters to the marco<\/p>\n<pre lang=\"cpp\">\r\n#define PrintWord(word) cout << word << endl;\r\n<\/pre>\n<p>will change the word parameter within the code to the passed value for example both will work<\/p>\n<pre lang=\"cpp\">\r\nvoid main()\r\n{\r\n       PrintWord(\"hi there\");\r\n       PrintWord(3);\r\n}\r\n<\/pre>\n<p>since the marco will convert the passed parameter to the value.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The define part of the c\/c++ language is able to save on coding time. The define is only really good for a one line of code that a function would be far to much of a over kill. Here are three examples of the define, #define MAXVALUE 20 this will allow for a hard coded &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2009\/07\/24\/define-the-marco-that-can-save-time\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Define &#8211; the marco that can save time<\/span><\/a><\/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":[10,9,8,398,400],"class_list":["post-139","post","type-post","status-publish","format-standard","hentry","category-c_and_cpp","tag-c","tag-gcc","tag-gnu","tag-linux","tag-windows"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/139","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=139"}],"version-history":[{"count":2,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/139\/revisions"}],"predecessor-version":[{"id":141,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/139\/revisions\/141"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}