{"id":9639,"date":"2022-05-16T04:00:19","date_gmt":"2022-05-16T04:00:19","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=9639"},"modified":"2023-09-25T12:37:16","modified_gmt":"2023-09-25T07:07:16","slug":"microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/","title":{"rendered":"Microcontroller Embedded C Programming Lecture 36| Address of variables contd."},"content":{"rendered":"<div class=\"boldgrid-section has-hover-bg hover-bg-396\" style=\"background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-hover-bg-class=\"hover-bg-396\" data-hover-bg-color=\"rgb(238, 238, 238)\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"container\">\n<div class=\"row\" style=\"padding-top: 35px; padding-bottom: 0px; background-image: linear-gradient(to left, #eeeeee, #eeeeee);\" data-bg-color-1=\"#EEEEEE\" data-bg-color-2=\"#EEEEEE\" data-bg-direction=\"to left\">\n<div class=\"col-md-1 col-sm-12 col-xs-12 col-lg-1\">\n<div class=\"boldgrid-shortcode\" data-imhwpb-draggable=\"true\">\n\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<div class=\"col-md-10 col-sm-12 col-xs-12 col-lg-10\">\n<h1 class=\"\" style=\"text-align: center; font-size: 30px; border-width: 0px; line-height: 50px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><strong>Address of variables contd.<\/strong><\/span><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px; margin-top: -25px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\n<p>&nbsp;<\/p>\n<div class=\"bg-hr bg-hr-10 color2-color\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">When working with variables in C, it&#8217;s essential to grasp the concept of memory addresses and how they can be stored in variables for various purposes. This tutorial will explore the use of the address-of operator (&amp;) and type casting to manage memory addresses effectively.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">When you use <\/span><b>&amp;a1<\/b><span style=\"font-weight: 400;\">, it actually gives the pointer. So now, you can even store this value into a variable.<\/span><\/span><\/p>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><strong>Storing Memory Addresses:<\/strong><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">In C, the <strong>ampersand (&amp;)<\/strong> operator allows you to retrieve the memory address of a variable.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">For example, <\/span>&nbsp;if we have a character variable named a1, &amp;a1 will give us the memory address of a1<\/span><span style=\"color: #000000;\"><span style=\"color: #000000; font-family: Roboto Slab;\">. You can also store this address in another variable for further manipulation.<\/span><\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px;\"><span style=\"color: #ff99cc;\">#include<\/span>&lt;stdio.h&gt;\r\n\r\n<span style=\"color: #ff99cc;\">int<\/span> main()\r\n{\r\n   <span style=\"color: #ff99cc;\">char<\/span> a1 = 'A';\r\n  \r\n<span style=\"color: #ff99cc;\">unsigned long int<\/span> addressOfa1 = &amp;a1;\r\n<span style=\"color: #ff00ff;\">printf<\/span>(\"Address of variable a1 = %p\\n\", &amp;a1);\r\n\r\nreturn 0;\r\n}<\/pre>\n<p class=\"\" style=\"text-align: center;\"><span style=\"color: #000000;\">Test this program in Eclipse IDE<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Now, if I do this, let&#8217;s see whether the compiler is happy with this or not. <\/span><\/span><span style=\"font-weight: 400; color: #000000;\">Build the project, and there is one important warning let&#8217;s read.<\/span><\/p>\n<p class=\"\" style=\"font-size: 20px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><strong>Compiler Warning:<\/strong><\/span><\/p>\n<blockquote class=\"\">\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\"> The warning says that <span style=\"color: #ff0000;\">&#8220;initialization of &#8216;long unsigned int&#8217; from &#8216;char *&#8217; makes integer from pointer without a cast&#8221;<\/span>.&nbsp;<\/span><\/p>\n<\/blockquote>\n<figure id=\"attachment_9643\" aria-describedby=\"caption-attachment-9643\" style=\"width: 687px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-9643 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/05\/Figure-2-11-1024x573.png\" alt=\"Figure 2. Warning \" width=\"687\" height=\"384\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11-1024x573.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11-300x168.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11-768x430.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11-600x336.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11-120x67.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11-500x280.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11-200x112.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11-400x224.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11-800x448.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11-1200x671.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-2-11.png 1280w\" sizes=\"(max-width: 687px) 100vw, 687px\" \/><figcaption id=\"caption-attachment-9643\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Warning<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">This warning arises because the memory address obtained from &amp;a1 is treated as a pointer, not a simple numeric value.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">You should remember that<\/span><b> &amp;a1<\/b><span style=\"font-weight: 400;\">&nbsp; is not a number. The compiler sees it as a pointer. There is a difference between a number and a pointer in &#8216;C.&#8217;&nbsp;<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_9644\" aria-describedby=\"caption-attachment-9644\" style=\"width: 721px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-9644 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/05\/Figure-3-11-1024x578.png\" alt=\"Figure 3. Analyze the code \" width=\"721\" height=\"407\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-1024x578.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-300x169.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-768x433.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-600x338.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-1536x866.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-120x68.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-500x282.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-200x113.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-400x226.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-800x451.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11-1200x677.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11.png 1881w\" sizes=\"(max-width: 721px) 100vw, 721px\" \/><figcaption id=\"caption-attachment-9644\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Analyze the code<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><strong>Data Type Mismatch:<\/strong><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Here, you are trying to assign <\/span><b>&amp;a1<\/b><span style=\"font-weight: 400;\"> entity to a variable <\/span><b>addressOfa1<\/b><span style=\"font-weight: 400;\">.So, addressOfa1 represents a variable. So, here the data type of this one is unsigned long int. We used unsigned long int because unsigned long is 8 bytes. So, the address size is 8 bytes. That&#8217;s why I have chosen unsigned long int. That&#8217;s about the left-hand side.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Now let&#8217;s take a look at the right-hand side. <\/span><b>&amp;a1<\/b><span style=\"font-weight: 400;\"> is pointer data. Pointer data are represented by pointer data type in &#8216;C.&#8217; So, the type here at the LHS is unsigned long int, and the type at the RHS is char*.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The warning is that you are trying to take an entity of a different data type, and you are trying to assign that to an entirely different data type variable. That&#8217;s why there is a data type mismatch. So, &amp;a1 is not just a number; this is a pointer, which belongs to the pointer data type. And the pointer data type happens to be char* in this case. When we cover pointers so you will understand more about that.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here, we are trying to assign a pointer type data into a variable. Hence there is a <strong>data type mismatch warning<\/strong>.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">To solve this issue, convert pointer data type into variable data type using type casting.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 20px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><strong>Solution: Type Casting:<\/strong><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">To resolve this issue, we use type casting. Type casting involves converting one data type into another.&nbsp;<\/span><\/p>\n<figure id=\"attachment_9645\" aria-describedby=\"caption-attachment-9645\" style=\"width: 706px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-9645 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/05\/Figure-4-9-1024x452.png\" alt=\"Figure 4. Typecasting \" width=\"706\" height=\"311\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-1024x452.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-300x132.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-768x339.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-600x265.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-1536x677.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-120x53.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-500x221.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-200x88.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-400x176.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-800x353.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9-1200x529.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-4-9.png 1789w\" sizes=\"(max-width: 706px) 100vw, 706px\" \/><figcaption id=\"caption-attachment-9645\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Typecasting<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"font-size: 17px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">In this case,&nbsp;<span style=\"font-weight: 400;\">Unsigned long int is called as typecasting.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">We are converting &amp;a1 entity into unsigned long int type. This whole thing is now a number. So now there is no pointer. So, we converted the pointer into a number of unsigned long int.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s see how the compiler responds to that. Let&#8217;s do the typecasting.<\/span><\/p>\n<figure id=\"attachment_9646\" aria-describedby=\"caption-attachment-9646\" style=\"width: 702px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-9646\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/05\/Figure-5-8-1024x472.png\" alt=\"Address Variables and Type Casting in C\" width=\"702\" height=\"324\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8-1024x472.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8-300x138.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8-768x354.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8-600x277.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8-120x55.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8-500x231.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8-200x92.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8-400x184.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8-800x369.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8-1200x553.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-5-8.png 1221w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><figcaption id=\"caption-attachment-9646\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Typecasting<\/span><\/figcaption><\/figure>\n<p data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 25px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Write the parenthesis and give this data type name <\/span><b>unsigned long int<\/b><span style=\"font-weight: 400;\">. And after that, let&#8217;s print <\/span><b>the addressOfa1<\/b><span style=\"font-weight: 400;\"> value just like an integer. For that Integer, we use %d.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">But remember that %d for integer, but this is a long integer, so %ld. Remember that you need not use %ld here. Because this is unsigned data, so addresses are always unsigned. That&#8217;s why, instead of giving %ld (which is for signed), you can mention <\/span><b>%lu<\/b><span style=\"font-weight: 400;\"> long unsigned integer.&nbsp;<\/span><span style=\"font-weight: 400;\">&nbsp;<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Let&#8217;s run this code.&nbsp;<\/span><\/p>\n<figure id=\"attachment_9647\" aria-describedby=\"caption-attachment-9647\" style=\"width: 716px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-9647\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/05\/Figure-6-5-1024x577.png\" alt=\"Address Variables and Type Casting in C\" width=\"716\" height=\"403\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5-1024x577.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5-300x169.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5-768x433.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5-600x338.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5-120x68.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5-500x282.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5-200x113.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5-400x225.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5-800x451.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5-1200x676.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-6-5.png 1272w\" sizes=\"(max-width: 716px) 100vw, 716px\" \/><figcaption id=\"caption-attachment-9647\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Warning message<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">You can see that the warning is changed to something else. Now, it says \u201ccast from pointer to integer of different size.\u201d So, this warning is coming because the unsigned long int is actually 4 bytes on my machine. Basically, it is compiler dependent as I said previously, so everything is compiler dependent here.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The size of the data type <\/span><b>int<\/b><span style=\"font-weight: 400;\"> is 4 bytes, and the size of the <\/span><b>long<\/b><span style=\"font-weight: 400;\"> data type is also 4 bytes for this compiler. So, that&#8217;s the reason the compiler is saying that here. So, <\/span><b>&amp;a1<\/b><span style=\"font-weight: 400;\"> is actually a pointer data of 8 bytes, and you are trying to truncate that by using long int.<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Here we have to use long long int. The long long size is 8 bytes. And to print long long data, you have to use an I64 format specifier. Just use <\/span><b>%I64<\/b><span style=\"font-weight: 400;\">.<\/span><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Basically, you can also use lld or llu. lld is for a long long integer, llu is for a long long unsigned integer. For MinGW, you have to use here I64d or I64u. So, since we are trying to print unsigned data, let&#8217;s use I64u.&nbsp;<\/span><\/p>\n<figure id=\"attachment_9648\" aria-describedby=\"caption-attachment-9648\" style=\"width: 662px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-9648\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/05\/Figure-7-4-1024x537.png\" alt=\"Address Variables and Type Casting in C\" width=\"662\" height=\"347\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4-1024x537.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4-300x157.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4-768x402.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4-600x314.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4-120x63.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4-500x262.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4-200x105.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4-400x210.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4-800x419.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4-1200x629.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-7-4.png 1273w\" sizes=\"(max-width: 662px) 100vw, 662px\" \/><figcaption id=\"caption-attachment-9648\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. Resolve the warning<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Compile and run this. There are no warnings at all. So, now let&#8217;s try to print this, so this happens in integer format. (Figure 6)<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">Let&#8217;s convert that into hex format. So you can give <\/span><b>X<\/b><span style=\"font-weight: 400;\"> here instead of <\/span><b>u<\/b><span style=\"font-weight: 400;\">. Now let&#8217;s run.<\/span><\/span><\/p>\n<figure id=\"attachment_9649\" aria-describedby=\"caption-attachment-9649\" style=\"width: 733px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-9649\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/05\/Figure-8-2-1024x550.png\" alt=\"Address Variables and Type Casting in C\" width=\"733\" height=\"394\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2-1024x550.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2-768x413.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2-600x323.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2-120x65.png 120w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2-500x269.png 500w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2-200x108.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2-400x215.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2-800x430.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2-1200x645.png 1200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-8-2.png 1466w\" sizes=\"(max-width: 733px) 100vw, 733px\" \/><figcaption id=\"caption-attachment-9649\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Convert into hex format<\/span><\/figcaption><\/figure>\n<p class=\"\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The output shows in a hex format. It is printing only 3 bytes because the rest of the bytes are 0. So, the takeaway from this lecture is you can store the pointer as a number(&amp;a1) in your variable(addressOfa1), but for that, you have to use some casting( unsigned long long int). So, here we are using long long int because the pointer is 8 bytes in this machine. That may not be true if you go to the other machine.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">For example, if we use ARM-based 32-bit microcontrollers, then the address size will be 4 bytes. It all depends on the architecture. The pointer size is actually architecture-driven. For 32-bit architecture, the pointer size will be 4 bytes; for 16-bit architecture, it will be 2 bytes, like that.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 17px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In the following article, let&#8217;s study functions in &#8216;C.&#8217;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 18px; line-height: 30px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #993366;\"><strong>Get Full Course on Microcontroller Embedded C Programming<\/strong> <span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/www.udemy.com\/course\/microcontroller-embedded-c-programming\/\">Here<\/a><\/span>.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 20px; line-height: 26px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000080;\"><b>FastBit Embedded Brain Academy Courses<\/b><\/span><\/p>\n<p class=\"\" style=\"border-width: 0px; font-size: 17px;\"><span style=\"color: #000000;\">C<span style=\"font-weight: 400;\"><span style=\"color: #000000;\">lick here:<\/span><span style=\"color: #0000ff;\">&nbsp;<\/span><\/span><\/span><span style=\"color: #0000ff;\"><a style=\"color: #0000ff; text-decoration: underline;\" href=\"http:\/\/fastbitlab.com\/course1\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/fastbitlab.com\/course1<\/span><\/a><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Address of variables contd. &nbsp; &nbsp; When working with variables in C, it&#8217;s essential to grasp the concept of memory addresses and how they can be stored in variables for various purposes. This tutorial will explore the use of the address-of operator (&amp;) and type casting to manage memory addresses effectively. When you use [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9644,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"0","ocean_second_sidebar":"0","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"0","ocean_custom_header_template":"0","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"0","ocean_menu_typo_font_family":"0","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"0","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"off","ocean_gallery_id":[],"footnotes":""},"categories":[8],"tags":[16],"class_list":["post-9639","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-microcontroller-embedded-c-programming","entry","has-media"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Understanding Address Variables and Type Casting in C<\/title>\n<meta name=\"description\" content=\"Address of variables contd. Learn how to obtain the address of variables in C programming using the &#039;&amp;&#039; operator and pointer type casting\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Understanding Address Variables and Type Casting in C\" \/>\n<meta property=\"og:description\" content=\"Address of variables contd. Learn how to obtain the address of variables in C programming using the &#039;&amp;&#039; operator and pointer type casting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/\" \/>\n<meta property=\"og:site_name\" content=\"FastBit EBA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/fastbiteba\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-16T04:00:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-25T07:07:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1881\" \/>\n\t<meta property=\"og:image:height\" content=\"1061\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"FastBitLab\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:site\" content=\"@fastbiteba\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FastBitLab\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Microcontroller Embedded C Programming Lecture 36| Address of variables contd.\",\"datePublished\":\"2022-05-16T04:00:19+00:00\",\"dateModified\":\"2023-09-25T07:07:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/\"},\"wordCount\":1127,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/Figure-3-11.png\",\"keywords\":[\"Microcontroller Embedded C programming Lectures\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/\",\"name\":\"Understanding Address Variables and Type Casting in C\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/Figure-3-11.png\",\"datePublished\":\"2022-05-16T04:00:19+00:00\",\"dateModified\":\"2023-09-25T07:07:16+00:00\",\"description\":\"Address of variables contd. Learn how to obtain the address of variables in C programming using the '&' operator and pointer type casting\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/Figure-3-11.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/05\\\/Figure-3-11.png\",\"width\":1881,\"height\":1061,\"caption\":\"Figure 3. Analyze the code\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microcontroller Embedded C Programming Lecture 36| Address of variables contd.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"name\":\"FastBit EBA\",\"description\":\"Your Online Academy of Embedded Systems\",\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\",\"name\":\"FastBit EBA\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/logo-EzNrEnyr.png\",\"width\":640,\"height\":640,\"caption\":\"FastBit EBA\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/fastbiteba\\\/\",\"https:\\\/\\\/x.com\\\/fastbiteba\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/fastbit-embedded-brain-academy-b3167b124\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCa1REBV9hyrzGp2mjJCagBg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\",\"name\":\"FastBitLab\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g\",\"caption\":\"FastBitLab\"},\"description\":\"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Understanding Address Variables and Type Casting in C","description":"Address of variables contd. Learn how to obtain the address of variables in C programming using the '&' operator and pointer type casting","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:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/","og_locale":"en_US","og_type":"article","og_title":"Understanding Address Variables and Type Casting in C","og_description":"Address of variables contd. Learn how to obtain the address of variables in C programming using the '&' operator and pointer type casting","og_url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-05-16T04:00:19+00:00","article_modified_time":"2023-09-25T07:07:16+00:00","og_image":[{"width":1881,"height":1061,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11.png","type":"image\/png"}],"author":"FastBitLab","twitter_card":"summary_large_image","twitter_creator":"@fastbiteba","twitter_site":"@fastbiteba","twitter_misc":{"Written by":"FastBitLab","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Microcontroller Embedded C Programming Lecture 36| Address of variables contd.","datePublished":"2022-05-16T04:00:19+00:00","dateModified":"2023-09-25T07:07:16+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/"},"wordCount":1127,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11.png","keywords":["Microcontroller Embedded C programming Lectures"],"articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/","url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/","name":"Understanding Address Variables and Type Casting in C","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11.png","datePublished":"2022-05-16T04:00:19+00:00","dateModified":"2023-09-25T07:07:16+00:00","description":"Address of variables contd. Learn how to obtain the address of variables in C programming using the '&' operator and pointer type casting","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/05\/Figure-3-11.png","width":1881,"height":1061,"caption":"Figure 3. Analyze the code"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-36-address-of-variables-contd\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Microcontroller Embedded C Programming Lecture 36| Address of variables contd."}]},{"@type":"WebSite","@id":"https:\/\/fastbitlab.com\/blog\/#website","url":"https:\/\/fastbitlab.com\/blog\/","name":"FastBit EBA","description":"Your Online Academy of Embedded Systems","publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fastbitlab.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fastbitlab.com\/blog\/#organization","name":"FastBit EBA","url":"https:\/\/fastbitlab.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2026\/04\/logo-EzNrEnyr.png","width":640,"height":640,"caption":"FastBit EBA"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/fastbiteba\/","https:\/\/x.com\/fastbiteba","https:\/\/www.linkedin.com\/in\/fastbit-embedded-brain-academy-b3167b124\/","https:\/\/www.youtube.com\/channel\/UCa1REBV9hyrzGp2mjJCagBg"]},{"@type":"Person","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d","name":"FastBitLab","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9230d0f9bdef28b63a01e7ca274ee7b2e8ed9abe932ee564af8809caaf52a0c8?s=96&d=mm&r=g","caption":"FastBitLab"},"description":"The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries."}]}},"_links":{"self":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/9639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/comments?post=9639"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/9639\/revisions"}],"predecessor-version":[{"id":16057,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/9639\/revisions\/16057"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/9644"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=9639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=9639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=9639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}