{"id":4798,"date":"2022-08-19T09:41:33","date_gmt":"2022-08-19T09:41:33","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4798"},"modified":"2022-08-19T09:42:34","modified_gmt":"2022-08-19T09:42:34","slug":"what-is-pointers-in-cpp","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/","title":{"rendered":"What is Pointers in C++ ?"},"content":{"rendered":"<ul>\n<li style=\"text-align: justify;\">Pointers are symbolic representation of addresses and it enables a program to simulate call-by-reference as well as to create and manipulate dynamic data structures.<\/li>\n<li style=\"text-align: justify;\">It defines a pointer variable and its general declaration in C\/C++ has the format.<\/li>\n<li style=\"text-align: justify;\">Using unary operator (&) assigning the address of a variable to a pointer which returns the address of that variable.<\/li>\n<li style=\"text-align: justify;\">Using unary operator (*) accessing the value stored in the address which returns the value of the variable located at the address specified by its operand.<\/li>\n<li style=\"text-align: justify;\">When we increment a pointer, we increase the pointer by the size of data type to which it points, this is the reason data type to a pointer is knows how many bytes the data is stored inside.<\/li>\n<\/ul>\n<h2 id=\"syntax\">Syntax<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-cpp code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-cpp code-embed-code\">datatype *var_name; <br\/>int *ptr;<\/code><\/pre> <\/div>\n<h2 id=\"sample-code\">Sample Code<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-cpp code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-cpp code-embed-code\">#include <iostream><br\/>using namespace std;<br\/>int main() {<br\/>\tint  x = 27;  <br\/>\tint  *ip;        <br\/>\tip = &x;       <br\/>\tcout << &quot;Value of x is : &quot;;<br\/>\tcout << x << endl;<br\/>\tcout << &quot;Value of ip is : &quot;;<br\/>\tcout << ip<< endl;<br\/>\tcout << &quot;Value of *ip is : &quot;;<br\/>\tcout << *ip << endl;<br\/>\treturn 0;<br\/>}<\/code><\/pre> <\/div>\n<h2 id=\"output\">Output<\/h2>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-4799\" src=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/pointers.png\" alt=\"\" width=\"541\" height=\"150\" srcset=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/pointers.png 541w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/pointers-300x83.png 300w, https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/pointers-390x108.png 390w\" sizes=\"(max-width: 541px) 100vw, 541px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pointers are symbolic representation of addresses and it enables a program to simulate call-by-reference as well as to create and manipulate dynamic data structures. It defines a pointer variable and its general declaration in C\/C++ has the format. Using unary operator (&#038;) assigning the address of a variable to a pointer which returns the address [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2080],"tags":[18415,18413,18416,1819,18414,18418,2539,18422,18419,18424,18421,18423,18425,18417,18420,18426,18427,18428],"class_list":["post-4798","post","type-post","status-publish","format-standard","hentry","category-cpp","tag-c-pointer","tag-c-pointers","tag-c-pointers-with-examples","tag-pointers-in-c","tag-pointers-in-c-c-with-examples","tag-smart-pointers-in-c","tag-types-of-pointers-in-c","tag-what-is-pointer-in-c-plus-plus","tag-what-is-pointer-in-c","tag-what-is-pointer-in-c-definition","tag-what-is-pointer-in-c-explain-with-example","tag-what-is-pointer-in-c-syntax","tag-what-is-pointer-in-c-types","tag-what-is-pointer-in-c-with-example","tag-what-is-pointers-in-c-language","tag-what-is-pointers-in-c-programming","tag-what-is-pointers-in-c-with-example","tag-what-is-pointers-in-cpp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What is Pointers in C++ - C++ Pointers with Examples - Pointers in C++<\/title>\n<meta name=\"description\" content=\"What is Pointers in C++ ? - Pointers are symbolic representation of addresses and it enables a program to simulate call-by-reference as well as to create.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Pointers in C++ - C++ Pointers with Examples - Pointers in C++\" \/>\n<meta property=\"og:description\" content=\"What is Pointers in C++ ? - Pointers are symbolic representation of addresses and it enables a program to simulate call-by-reference as well as to create.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-19T09:41:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-19T09:42:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/pointers.png\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/\"},\"author\":{\"name\":\"webmaster\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/f785ba3ecc599133e65ab6138042a3e4\"},\"headline\":\"What is Pointers in C++ ?\",\"datePublished\":\"2022-08-19T09:41:33+00:00\",\"dateModified\":\"2022-08-19T09:42:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/\"},\"wordCount\":242,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pointers.png\",\"keywords\":[\"c++ pointer\",\"c++ pointers\",\"c++ pointers with examples\",\"pointers in c\",\"pointers in c++\\\/c++ with examples\",\"smart pointers in c++\",\"types of pointers in c\",\"what is pointer in c plus plus\",\"what is pointer in c++\",\"what is pointer in c++ definition\",\"what is pointer in c++ explain with example\",\"what is pointer in c++ syntax\",\"what is pointer in c++ types\",\"what is pointer in c++ with example\",\"what is pointers in c++ language\",\"what is pointers in c++ programming\",\"what is pointers in c++ with example\",\"what is pointers in cpp\"],\"articleSection\":[\"C++\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/\",\"name\":\"What is Pointers in C++ - C++ Pointers with Examples - Pointers in C++\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pointers.png\",\"datePublished\":\"2022-08-19T09:41:33+00:00\",\"dateModified\":\"2022-08-19T09:42:34+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What is Pointers in C++ ? - Pointers are symbolic representation of addresses and it enables a program to simulate call-by-reference as well as to create.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/cpp\\\/what-is-pointers-in-cpp\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pointers.png\",\"contentUrl\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pointers.png\",\"width\":541,\"height\":150},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#website\",\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/#\\\/schema\\\/person\\\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\"],\"url\":\"https:\\\/\\\/www.wikitechy.com\\\/interview-questions\\\/author\\\/webmaster\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Pointers in C++ - C++ Pointers with Examples - Pointers in C++","description":"What is Pointers in C++ ? - Pointers are symbolic representation of addresses and it enables a program to simulate call-by-reference as well as to create.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/","og_locale":"en_US","og_type":"article","og_title":"What is Pointers in C++ - C++ Pointers with Examples - Pointers in C++","og_description":"What is Pointers in C++ ? - Pointers are symbolic representation of addresses and it enables a program to simulate call-by-reference as well as to create.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/","og_site_name":"Wikitechy","article_published_time":"2022-08-19T09:41:33+00:00","article_modified_time":"2022-08-19T09:42:34+00:00","og_image":[{"url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/pointers.png","type":"","width":"","height":""}],"author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/#article","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/"},"author":{"name":"webmaster","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"headline":"What is Pointers in C++ ?","datePublished":"2022-08-19T09:41:33+00:00","dateModified":"2022-08-19T09:42:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/"},"wordCount":242,"commentCount":0,"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/pointers.png","keywords":["c++ pointer","c++ pointers","c++ pointers with examples","pointers in c","pointers in c++\/c++ with examples","smart pointers in c++","types of pointers in c","what is pointer in c plus plus","what is pointer in c++","what is pointer in c++ definition","what is pointer in c++ explain with example","what is pointer in c++ syntax","what is pointer in c++ types","what is pointer in c++ with example","what is pointers in c++ language","what is pointers in c++ programming","what is pointers in c++ with example","what is pointers in cpp"],"articleSection":["C++"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/","name":"What is Pointers in C++ - C++ Pointers with Examples - Pointers in C++","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/#primaryimage"},"image":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/pointers.png","datePublished":"2022-08-19T09:41:33+00:00","dateModified":"2022-08-19T09:42:34+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What is Pointers in C++ ? - Pointers are symbolic representation of addresses and it enables a program to simulate call-by-reference as well as to create.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/what-is-pointers-in-cpp\/#primaryimage","url":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/pointers.png","contentUrl":"https:\/\/www.wikitechy.com\/interview-questions\/wp-content\/uploads\/2022\/08\/pointers.png","width":541,"height":150},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4798","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4798"}],"version-history":[{"count":1,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4798\/revisions"}],"predecessor-version":[{"id":4800,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4798\/revisions\/4800"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}