{"id":81822,"date":"2021-07-17T09:00:30","date_gmt":"2021-07-17T03:30:30","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=81822"},"modified":"2021-07-17T09:00:30","modified_gmt":"2021-07-17T03:30:30","slug":"pointers-in-c-language","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/","title":{"rendered":"Pointers in C with Examples"},"content":{"rendered":"<p>The C programming language offers various features and functionalities to its users. And pointers are one of them. Pointers help programmers in better coding. With the help of a pointer, you can work with different memory addresses of different variables. It is one of the most powerful and useful features of the C programming language.<\/p>\n<p>Let me tell you about addresses in C before we start with pointers.<\/p>\n<h3>Address in C<\/h3>\n<p>Whenever a variable is defined then you can access the memory address of that variable. Suppose, you define a variable named var then if you use <strong>&amp;var,<\/strong> it will give the variable var\u2019s address in memory. In C, you can get the memory address of a variable using<strong> &amp;<\/strong> symbol.<\/p>\n<p><strong>Example of Address in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;stdio.h&gt;\n\nint main()\n{\n  int var = 2;\n  printf(\"Value is: %d\\n\", var);\n  printf(\"Memory address is: %p\\n\", &amp;var);\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">Value is: 2<br \/>\nMemory address is: 0x7ffcd857e2dc<\/div>\n<h3>What is a pointer in C?<\/h3>\n<p>The main purpose of a pointer is to get the memory address of the variable which is defined in the program code. Pointers are special variables. It holds the memory address of another variable of the same data type. Without the help of a pointer, you cannot perform tasks such as dynamic memory allocation and many tasks in the C programming language.<\/p>\n<p><strong>Example of pointer in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int a=5;\nint* point = &amp;a; \/\/ pointer variable point is pointing to the address of the integer variable a!\n<\/pre>\n<h3>How to use pointers in C?<\/h3>\n<ul>\n<li>First, you should define a pointer variable.<\/li>\n<li>Then, assign the address of a variable to that pointer using <strong>&amp;<\/strong> symbol. It will return the address of that variable.<\/li>\n<li>You can access the value stored in that address by using <strong>*(asterisk)<\/strong> symbol.<\/li>\n<\/ul>\n<p>We associate data type to a pointer because it knows how much bytes of data can it store.<\/p>\n<p><strong>Basic example of pointers in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nvoid TechVidvan()\n{\n  int var = 25;\n  int *pt;\n  pt = &amp;var;    \n  printf(\"Address is: %p \\n\",pt);\n  printf(\"Value is: %d \\n\", *pt);\t \n}\nint main()\n{\n  TechVidvan();\n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">Address is: 0x7ffc9e1fb704<br \/>\nValue is: 25<\/div>\n<h3>Declare a pointer in C<\/h3>\n<p>In C, you can declare a pointer variable using <strong>*(asterisk)<\/strong> symbol.<\/p>\n<p><strong>Syntax:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int* p;\nchar* c;<\/pre>\n<p>In the above, we have declared a pointer <strong>p<\/strong> of type <strong>int<\/strong> and also declared a pointer <strong>c<\/strong> of type <strong>char.<\/strong><\/p>\n<p>You can also declare a pointer variable like below:-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int* v1,v2;\n<\/pre>\n<p>In the above, we have declared a pointer v1 and a normal variable v2.<\/p>\n<p><strong>Example of how to Declare a pointer in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;stdio.h&gt;\n\nint main()\n{\n  int val = 10;\n  int* point;\n  point = &amp;val;\n  printf(\"TechVidvan Tutorial: Declare a pointer in C!\\n\\n\");\n  printf(\"Value is: %d\\n\", *point);\n  printf(\"Memory address is: %p\\n\", point);\n}\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Declare a pointer in C!<\/p>\n<p>Value is: 10<br \/>\nMemory address is: 0x7ffdcf71bb14<\/p>\n<\/div>\n<p>In the above example, the address of the value is assigned to the pointer variable named <strong>point.<\/strong> And we have used <strong>*point<\/strong> to get the value that is stored in that address.<\/p>\n<h3>Changing the value in C pointers<\/h3>\n<p>In C, we can also change the value pointed by the pointers easily.<\/p>\n<p>Let\u2019s take the above example. From the above example, we can change the value of the integer variable <strong>val<\/strong> like below:-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;stdio.h&gt;\n\nint main()\n{\n  int val = 10;\n  int* point;\n  point = &amp;val;\n  val = 9;\n  printf(\"TechVidvan Tutorial: Changing the value pointed by a pointer!\\n\\n\");\n  printf(\"Value is: %d\\n\", *point);\n  printf(\"Memory address is: %p\\n\", point);\n}<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Changing the value pointed by a pointer!<\/p>\n<p>Value is: 9<br \/>\nMemory address is: 0x7ffc167b00a4<\/p>\n<\/div>\n<p>See, we have changed the value of <strong>val<\/strong> variable from 10 to 9. And the memory address is also different.<\/p>\n<h3>More About C Pointers<\/h3>\n<p>In C, pointers have various useful concepts that a programmer must learn. Following are some important concepts in pointers:-<\/p>\n<h4>Pointer Arithmetic Operators<\/h4>\n<p>In a pointer, you can use four arithmetic operators such as ++, &#8211;, + and &#8211; on pointers. With the help of this, you can perform certain arithmetic operations on pointers.<\/p>\n<h4>Incrementing a pointer<\/h4>\n<p>In C, you can also increment a pointer. You can use an array which will help you increment the pointer easily.<\/p>\n<p><strong>Example of incrementing a pointer<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nint main () {\n   int value_array[] = {141, 1};\n   int *point;\n   point = value_array;\n   for (int a = 0; a &lt; 2; a++) {\n  printf(\"TechVidvan Tutorial: Incrementing a pointer!\\n\\n\");\n  printf(\"Value of value_array[%d] = %d\\n\", a, *point);\n  printf(\"Address of value_array[%d] = %p\\n\", a, point);\n  point++; \/\/ incrementing the pointer variable!\n   }\n   return 0;\n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Incrementing a pointer!<\/p>\n<p>Value of value_array[0] = 141<br \/>\nAddress of value_array[0] = 0x7ffe22d0679c<br \/>\nTechVidvan Tutorial: Incrementing a pointer!<\/p>\n<p>Value of value_array[1] = 1<br \/>\nAddress of value_array[1] = 0x7ffe22d067a0<\/p>\n<\/div>\n<h4>Decrementing a pointer in C<\/h4>\n<p>The C programming language also has the functionality to decrement a pointer.<\/p>\n<p><strong>Example of Decrementing a C pointer<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nint main () {\n   int value_array[] = {141, 1032};\n   int *point;\n   int max=2;\n   point = &amp;value_array[max-1];\n   for (int a = max; a &gt; 0; a--) {\n  printf(\"TechVidvan Tutorial: Decrementing a pointer!\\n\\n\");\n  printf(\"Value of value_array[%d] = %d\\n\", a-1, *point);\n  printf(\"Address of value_array[%d] = %p\\n\", a-1, point);\n  point--; \/\/ decrementing the pointer variable!\n   }\n   return 0;\n}<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Decrementing a pointer!<\/p>\n<p>Value of value_array[1] = 1032<br \/>\nAddress of value_array[1] = 0x7ffeafc6efac<br \/>\nTechVidvan Tutorial: Decrementing a pointer!<\/p>\n<p>Value of value_array[0] = 141<br \/>\nAddress of value_array[0] = 0x7ffeafc6efa8<\/p>\n<\/div>\n<h4>Pointer Comparison in C<\/h4>\n<p>You can also compare pointers by using relational operators like ==, &lt;, and &gt;.<\/p>\n<p><strong>Example of C Pointer Comparison<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nint main () {\n   int value_array[] = {141, 1032};\n   int *point;\n   int max=2;\n   int a=0;\n   point = value_array;\n   while(point &lt;= &amp;value_array[max-1]) {\n  printf(\"TechVidvan Tutorial: Pointer Comparison!\\n\\n\");\n  printf(\"Value of value_array[%d] = %d\\n\", a, *point);\n  printf(\"Address of value_array[%d] = %p\\n\", a, point);\n  point++;\n  a++;\n   }\n   return 0;\n}<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Pointer Comparison!<\/p>\n<p>Value of value_array[0] = 141<br \/>\nAddress of value_array[0] = 0x7fff9f245d68<br \/>\nTechVidvan Tutorial: Pointer Comparison!<\/p>\n<p>Value of value_array[1] = 1032<br \/>\nAddress of value_array[1] = 0x7fff9f245d6c<\/p>\n<\/div>\n<p>In the above example, we are incrementing the pointer variable until the address which the pointer points to is less than or equal to the address of the last element of the array.<\/p>\n<h4>Array of Pointers in C<\/h4>\n<p>In C, we can use an array of pointers to make your coding simple and easy.<\/p>\n<p><strong>For Example:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int *point[4];<\/pre>\n<p>In the above example, we have declared <strong>point<\/strong> as an array of 4 integer pointers. And each element in the point variable holds a pointer to an integer value.<\/p>\n<p><strong>Example ofArray of pointers in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nint main () {\n\n   int  value_array[] = {42, 366, 458, 112};\n   int a, *point[4];\n   printf(\"TechVidvan Tutorial: Array of pointers!\\n\\n\");\n \n   for (a = 0; a &lt; 4; a++) {\n  \tpoint[a] = &amp;value_array[a]; \/\/ assigning address!\n   }\n   for (a= 0; a &lt; 4; a++) {\n  \tprintf(\"Value =&gt; var[%d]: %d\\n\", a, *point[a] );\n   }\n   \n   return 0;\n}\n<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Array of pointers!<\/p>\n<p>Value =&gt; var[0]: 42<br \/>\nValue =&gt; var[1]: 366<br \/>\nValue =&gt; var[2]: 458<br \/>\nValue =&gt; var[3]: 112<\/p>\n<\/div>\n<p>In the above example, we used an array of integers but you can use an array of characters also.<\/p>\n<h4>Pointer to Pointer in C<\/h4>\n<p>Pointer to pointer is known as a chain of pointers. It means that the first pointer contains the address of the second pointer and it points to the location of actual value.<\/p>\n<p><strong>Syntax:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int **point;<\/pre>\n<p>In the above example, we declared a pointer to pointer of type integer.<\/p>\n<p><strong>Example of Pointer to pointer<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nint main () {\n   int  val;\n   int  *pt;\n   int  **point;\n\n   val = 55;\n   pt = &amp;val;\n   point = &amp;pt;\n   printf(\"Value =&gt; val: %d\\n\", val);\n   printf(\"Value =&gt; *pt: %d\\n\", *pt );\n   printf(\"Value =&gt; **pptr: %d\\n\", **point);\n   return 0;\n}<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">Value =&gt; val: 55<br \/>\nValue =&gt; *pt: 55<br \/>\nValue =&gt; **pptr: 55<\/div>\n<h4>Passing pointers to function in C<\/h4>\n<p>You can also pass a pointer to a function. You can just simply declare the function parameter as a pointer type.<\/p>\n<p><strong>Example of Passing pointers to function<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nvoid display(int *val);\nint main () {\n\n   int a;\n   display(&amp;a);\n   printf(\"TechVidvan Tutorial: Passing pointers to function!\\n\\n\");\n   printf(\"Value is: %d\\n\",a);\n   return 0;\n}\n\nvoid display(int *val) {\n   *val = 1002;\n  return;\n}<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Passing pointers to function!<\/p>\n<p>Value is: 1002<\/p>\n<\/div>\n<h4>Return pointers from function in C<\/h4>\n<p>In C, you have seen that you can return an array from a function. In a similar way, you can also return a pointer from a function.<\/p>\n<p><strong>NOTE:-<\/strong> If you try to return the address of a local variable outside the function then the local variables of the function will go out of scope. And your program will never get executed.<\/p>\n<p>So to avoid this type of error, you have to define the local variable as a static variable.<\/p>\n<p><strong>Example:- Return a pointer from a function<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\nint* printToscreen()\n{\n  static int val = 2364; \/\/ defining the local variable as static to avoid execution error!\n  return (&amp;val); \/\/ function returning pointer!\n}\nint main()\n{\n  int* point;\n  point = printToscreen();\n  printf(\"TechVidvan Tutorial: Returning pointer from a function!\\n\\n\");\n  printf(\"Address is: %p\\n\", point);\n  printf(\"Value is: %d\\n\", *point);\n  return 0;\n}<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Returning pointer from a function!<\/p>\n<p>Address is: 0x601048<br \/>\nValue is: 2364<\/p>\n<\/div>\n<h4>Invalid Pointers in C<\/h4>\n<p>A pointer is known as a invalid pointer when it does not point to valid elements. You can also state that Uninitialized pointers are also known as invalid pointers.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int *a;\nint ar[10];\nint *point = ar+20;<\/pre>\n<p>In the above example, <strong>*a<\/strong> pointer is uninitialized so it is an invalid pointer. And the pointer variable point is exceeding the limit of array <strong>ar.<\/strong> So, it is also an invalid pointer.<\/p>\n<h4>Null Pointers in C<\/h4>\n<p>A pointer that points to nowhere then it is known as null pointers. There are two methods to assign a null pointer:-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int *point1 = 0;\nint *point2 = NULL;<\/pre>\n<h4>Benefits of using pointers in C<\/h4>\n<ul>\n<li>Pointers help you to reduce the length and the execution of the program.<\/li>\n<li>Using a pointer, you can perform dynamic memory allocation easily.<\/li>\n<li>With pointers, it is easy to handle and implement arrays and structures.<\/li>\n<\/ul>\n<h4>Pointer to Structure in C<\/h4>\n<p>As you have seen, you can use an array to structure. Similarly, you can use a pointer to the structure. If you use pointers to a structure then you will have to use -&gt; operator to access the members of the structure.<\/p>\n<p><strong>Example of structure pointer in C<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include&lt;stdio.h&gt;\nstruct point\n{\n   int a;\n   float b;\n};\nint main()\n{\n   struct point p1={3,6.3};\n   struct point *p2=&amp;p1;\n   printf(\"TechVidvan Tutorial: Pointer to structures!\\n\\n\");\n   printf(\"First value is: %d\\n\",p2-&gt;a);\n   printf(\"Second value is: %0.1f\",p2-&gt;b);\n   return 0;\n}<\/pre>\n<p><strong>Output:-<\/strong><\/p>\n<div class=\"code-output\">\n<p>TechVidvan Tutorial: Pointer to structures!<\/p>\n<p>First value is: 3<br \/>\nSecond value is: 6.3<\/p>\n<\/div>\n<h4>Usage of Pointers in C<\/h4>\n<p>There are many uses of pointers in C programming.<\/p>\n<ul>\n<li><strong>Dynamic Memory Allocation:-<\/strong> With the help of pointers, we can easily allocate memory dynamically using calloc() and malloc() functions in C.<\/li>\n<li><strong>Arrays, Functions and Structures:-<\/strong> With pointers, it is easy to handle and implement arrays and structures. It helps in reducing code complexity and the execution time.<\/li>\n<\/ul>\n<h4>Complex Pointers in C<\/h4>\n<p>You must know that there are some complex pointers available in C. Below is a table of the precedence and associativity of the operators which are used regarding pointers.<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Operator<\/strong><\/td>\n<td><strong>Precedence<\/strong><\/td>\n<td><strong>Associativity<\/strong><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">(), []<\/span><\/td>\n<td><span style=\"font-weight: 400\">1<\/span><\/td>\n<td><span style=\"font-weight: 400\">Left to Right<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">*, identifier\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400\">2<\/span><\/td>\n<td><span style=\"font-weight: 400\">Right to Left<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">Data Type<\/span><\/td>\n<td><span style=\"font-weight: 400\">3<\/span><\/td>\n<td><span style=\"font-weight: 400\">_<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li><strong>():-<\/strong> Used to declare and define a function.<\/li>\n<li><strong>[]:-<\/strong> Used to represent an array.<\/li>\n<li><strong>*:-<\/strong> A pointer operator.<\/li>\n<li><strong>Identifier:-<\/strong> Name of the pointer.<\/li>\n<li><strong>Data Type:-<\/strong> It is the type of the variable to which the pointer points to.<\/li>\n<\/ul>\n<h4>Read the pointer in C<\/h4>\n<p>Before starting to read a pointer, you have to check that if<strong> () and []<\/strong> have the equal precedence. And also look for the associativity.<\/p>\n<p><strong>Example:-<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int (*point)[2]<\/pre>\n<p>In the above example, you will notice that the associativity is left to right. In that case, the priority goes to (). Inside the bracket, you will notice that <strong>*(pointer operator)<\/strong> and<strong> point(Identifier)<\/strong> have the same precedence. So, the associativity will go right to left. First priority goes to <strong>point<\/strong> and second priority goes to *. At last, you can say that point is a pointer to an array of integers of size 2.<\/p>\n<h3>Summary<\/h3>\n<p>From the above tutorial, we learnt about pointers. We also discussed some important topics and concepts such as Address in C, Pointer to Pointer, Array to pointer, Passing pointer to a function, Applications of pointer etc. Programmers will gain various benefits by using pointers in C.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The C programming language offers various features and functionalities to its users. And pointers are one of them. Pointers help programmers in better coding. With the help of a pointer, you can work with&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":82875,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3510],"tags":[3779,3780,3781],"class_list":["post-81822","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-programming","tag-declare-pointer-in-c","tag-null-pointer-in-c","tag-pointers-in-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pointers in C with Examples - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn about pointers in C. Learn Address in C, Pointer to Pointer, Array to pointer, Passing pointer to a function &amp; Applications of pointer.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pointers in C with Examples - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn about pointers in C. Learn Address in C, Pointer to Pointer, Array to pointer, Passing pointer to a function &amp; Applications of pointer.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-17T03:30:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Pointers-in-C.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pointers in C with Examples - TechVidvan","description":"Learn about pointers in C. Learn Address in C, Pointer to Pointer, Array to pointer, Passing pointer to a function & Applications of pointer.","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:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/","og_locale":"en_US","og_type":"article","og_title":"Pointers in C with Examples - TechVidvan","og_description":"Learn about pointers in C. Learn Address in C, Pointer to Pointer, Array to pointer, Passing pointer to a function & Applications of pointer.","og_url":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-07-17T03:30:30+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Pointers-in-C.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Pointers in C with Examples","datePublished":"2021-07-17T03:30:30+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/"},"wordCount":1578,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Pointers-in-C.jpg","keywords":["Declare pointer in C","Null pointer in C","Pointers in C"],"articleSection":["C Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/","url":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/","name":"Pointers in C with Examples - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Pointers-in-C.jpg","datePublished":"2021-07-17T03:30:30+00:00","description":"Learn about pointers in C. Learn Address in C, Pointer to Pointer, Array to pointer, Passing pointer to a function & Applications of pointer.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Pointers-in-C.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/06\/Pointers-in-C.jpg","width":1200,"height":628,"caption":"Pointers in C"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/pointers-in-c-language\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Pointers in C with Examples"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/81822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=81822"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/81822\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/82875"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=81822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=81822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=81822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}