{"id":1376,"date":"2013-05-17T05:22:42","date_gmt":"2013-05-16T19:22:42","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=1376"},"modified":"2015-07-21T11:11:45","modified_gmt":"2015-07-21T01:11:45","slug":"function-pointers-in-c-and-c-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/function-pointers-in-c-and-c-primer-tutorial\/","title":{"rendered":"Function Pointers in C and C++ Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/FunctionPointerArray\/\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Function Pointers in C and C++ Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/FunctionPointerArray\/C_Function_Pointers-6of.jpg\" title=\"Function Pointers in C and C++ Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Function Pointers in C and C++ Primer Tutorial<\/p><\/div>\n<p>When programming C and C++ you often talk about functions and methods respectively as a way to compartmentalize the work that your program needs to do.   Have you found yourself having these functions and methods well defined and similarly structured in terms of return types and argument types, yet doing different things, and you can define, in a switch statement, for instance, which one you&#8217;d want to do at any one particular part of your program execution.    This is where Function Pointers, optionally arranged into arrays, can be a good thing to learn about, as we do in this primer tutorial written in XCode C and C++.<\/p>\n<p><b>Background reading for tutorial:<\/p>\n<ul>\n<li><a target=_blank title='typedef' href='http:\/\/en.wikipedia.org\/wiki\/Typedef\u200e'>typedef<\/a><\/li>\n<li><a target=_blank title='arrays' href='http:\/\/en.wikipedia.org\/wiki\/Array_data_structure\u200e'>arrays<\/a><\/li>\n<li><a target=_blank title='pointers' href='http:\/\/en.wikipedia.org\/wiki\/Pointer_%28computer_programming%29'>pointers<\/a><\/li>\n<li><a target=_blank title='function pointers' href='http:\/\/en.wikipedia.org\/wiki\/Function_pointer'>function pointers<\/a><\/li>\n<li><a target=_blank title='switch' href='http:\/\/en.wikipedia.org\/wiki\/Switch_statement'>switch<\/a><\/li>\n<li><a target=_blank title='malloc' href='http:\/\/en.wikipedia.org\/wiki\/C_dynamic_memory_allocation'>malloc<\/a><\/li>\n<\/ul>\n<p><\/b>\n<\/p>\n<p>Here is a tutorial that introduces you to some C and C++ programming code for Function Pointers in an array &#8230;<\/p>\n<p>Let&#8217;s see some <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/FunctionPointerArray\/'>C and C++ via XCode<\/a> for this &#8230;<\/p>\n<p>Link to some downloadable C programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/FunctionPointerArray\/main.cpp_GETME' title='Download me'>main.cpp<\/a>  (or main.c &#8230; see how XCode can do C as well!) for use.<br \/>\nLink to some downloadable C++ programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/CPlusPlus\/FunctionPointerArray\/main.cpp-GETME' title='Download me'>main.cpp<\/a>.\n<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d1376' onclick='var dv=document.getElementById(\"d1376\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=C%2B%2B\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d1376' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>When programming C and C++ you often talk about functions and methods respectively as a way to compartmentalize the work that your program needs to do. Have you found yourself having these functions and methods well defined and similarly structured &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/function-pointers-in-c-and-c-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/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":[12,37,40],"tags":[176,473,960,1637,997,1319,1473],"class_list":["post-1376","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","category-xcode","tag-c","tag-function-pointers","tag-pointer","tag-pointers","tag-programming","tag-tutorial","tag-xcode"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/1376"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=1376"}],"version-history":[{"count":1,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/1376\/revisions"}],"predecessor-version":[{"id":16103,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/1376\/revisions\/16103"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=1376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=1376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=1376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}