{"id":12257,"date":"2022-11-12T10:39:21","date_gmt":"2022-11-12T05:09:21","guid":{"rendered":"http:\/\/fastbitlab.com\/?p=12257"},"modified":"2023-09-20T14:52:26","modified_gmt":"2023-09-20T09:22:26","slug":"microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/","title":{"rendered":"Microcontroller Embedded C Programming Lecture 131 | &#8216;const&#8217; usage and different case studies"},"content":{"rendered":"<div class=\"boldgrid-section\" style=\"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=\"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: 34px; border-width: 0px; line-height: 50px;\"><strong><span style=\"color: #000080;\">&#8216;const&#8217; usage and different case studies<\/span><\/strong><\/h1>\n<div class=\"row bg-editor-hr-wrap color-4-text-contrast color4-background-color\" style=\"border-width: 0px; margin: -40px 25px -50px; border-style: none; padding: 0em;\">\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\" style=\"border-style: solid; border-width: 0px 0px 3px;\"><\/div>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span class=\"\" style=\"font-weight: 400; color: #000000; border-width: 0px;\">In this article, let&#8217;s understand const pointer and will go through a different case study involving const with pointer.<\/span><\/p>\n<p class=\"\" style=\"border-width: 0px;\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span class=\"\" style=\"font-weight: 400; color: #000000; border-width: 0px; font-family: Roboto;\" data-font-family=\"Roboto\" data-font-weight=\"400\" data-font-style=\"\">The first case is&nbsp; <span class=\"\" style=\"color: #000080; border-width: 0px; font-family: Roboto; font-weight: 400;\" data-font-family=\"Roboto\" data-font-weight=\"400\" data-font-style=\"\"><strong class=\"\" style=\"border-width: 0px; font-family: Arial, Helvetica, sans-serif; font-weight: 400;\" data-font-family=\"Arial\" data-font-weight=\"400\" data-font-style=\"\">constant data<\/strong><\/span>.<\/span><\/p>\n<figure id=\"attachment_12260\" aria-describedby=\"caption-attachment-12260\" style=\"width: 642px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-12260 \" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/11\/Figure-1-3.png\" alt=\"Figure 1. Case 1: Constant data\" width=\"642\" height=\"306\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3.png 1841w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3-300x143.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3-1024x488.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3-768x366.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3-600x286.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3-1536x732.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3-200x95.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3-400x191.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3-800x381.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3-1200x572.png 1200w\" sizes=\"(max-width: 642px) 100vw, 642px\" \/><figcaption id=\"caption-attachment-12260\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Case 1: Constant data<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\"><span style=\"color: #ff0000;\">uint8_t const <\/span>data = 50 is a case of constant data.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span class=\"\" style=\"font-weight: 400; color: #800000; border-width: 0px; font-family: Oswald;\" data-font-family=\"Oswald\" data-font-weight=\"400\" data-font-style=\"\">What are the use cases of this?<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">You can use this case to define mathematical constants in the program. Like to define the value of pi or any mathematical constants,&nbsp; which you use in your application.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The second case is using the \u2018const\u2019 keyword with pointers.&nbsp; <\/span><\/p>\n<figure id=\"attachment_12261\" aria-describedby=\"caption-attachment-12261\" style=\"width: 562px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-12261\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/11\/Figure-2-3.png\" alt=\"'const' usage and different case studies in C\" width=\"562\" height=\"276\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-2-3.png 1849w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-2-3-300x147.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-2-3-1024x502.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-2-3-768x377.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-2-3-600x294.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-2-3-1536x753.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-2-3-200x98.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-2-3-400x196.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-2-3-800x392.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-2-3-1200x589.png 1200w\" sizes=\"(max-width: 562px) 100vw, 562px\" \/><figcaption id=\"caption-attachment-12261\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Case 2: Modifiable pointer and constant data<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Case 2 is <span style=\"color: #000080;\"><strong>modifiable pointer and constant data<\/strong>.<\/span><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; 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;\">Here, you observe<\/span><span style=\"font-weight: 400;\">&nbsp; <span style=\"color: #ff0000;\">uint8_t *pData = (uint8_t*) 0x10000000<\/span><\/span><span style=\"font-weight: 400;\"> statement.&nbsp; *pData is a pointer variable definition and it is initialized to the address 0x40000000.&nbsp;&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Just introduce const here.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #ff0000;\">uint8_t const *pData = (uint8_t*) 0x40000000;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This is the case of modifiable pointer and constant data.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">That means, here the pointer pData is modifiable but the data pointed by the pData cannot be modifiable, that is read-only. That means here the data is read-only not a pointer remember.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">So, we can say that pData is a pointer pointing to read-only data.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now let&#8217;s understand how to read this statement.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">First, identify the variable,*pData is a variable, and move to the left. So, pData is a pointer pointing to constant data of type uint8_t. That&#8217;s how you should read it.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Figure 3 shows the allowed and Not-Allowed statements.<\/span><\/p>\n<figure id=\"attachment_12262\" aria-describedby=\"caption-attachment-12262\" style=\"width: 578px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-12262\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/11\/Figure-3-1.png\" alt=\"const in C\" width=\"578\" height=\"259\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-3-1.png 1737w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-3-1-300x135.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-3-1-1024x459.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-3-1-768x344.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-3-1-600x269.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-3-1-1536x689.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-3-1-200x90.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-3-1-400x179.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-3-1-800x359.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-3-1-1200x538.png 1200w\" sizes=\"(max-width: 578px) 100vw, 578px\" \/><figcaption id=\"caption-attachment-12262\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Allowed and not allowed statements<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">In allowed statements, you can change the value of the pointer variable. That means you can assign different addresses to the *pData pointer variable. So that statements are allowed(as shown in Figure 3).&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">But *pData = 50 is not allowed. That means you cannot be able to modify the data pointed by the pointer.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span class=\"\" style=\"font-weight: 400; color: #800000; border-width: 0px; font-family: Oswald;\" data-font-family=\"Oswald\" data-font-weight=\"400\" data-font-style=\"\">What is a use case of modifiable pointer and constant data?<\/span><\/p>\n<figure id=\"attachment_12263\" aria-describedby=\"caption-attachment-12263\" style=\"width: 649px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-12263\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/11\/Figure-4-1.png\" alt=\"const in C\" width=\"649\" height=\"337\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-4-1.png 1889w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-4-1-300x156.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-4-1-1024x532.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-4-1-768x399.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-4-1-600x312.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-4-1-1536x798.png 1536w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-4-1-200x104.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-4-1-400x208.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-4-1-800x415.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-4-1-1200x623.png 1200w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><figcaption id=\"caption-attachment-12263\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Modifiable pointer and constant data<\/span><\/figcaption><\/figure>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here, look at one example. Consider the copy_src_to_dst function . This function copies data from the source pointer to the destination pointer.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here when you take a look into the first function implementation, whatever the data which is pointed by the source that is the source pointer needs to be copied into the destination. And then destination pointer should be increased to point to the next location and the source pointer needs to be incremented to point to the next location until all length bytes are copied.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Here, the guy who is implementing this function if he ever tries to do something like this src is equal to some other value. The compiler will not alert him in this case. The compiler will be quiet. <\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span class=\"\" style=\"font-weight: 400; color: #800000; border-width: 0px; font-family: Oswald;\" data-font-family=\"Oswald\" data-font-weight=\"400\" data-font-style=\"\">What is the goal of this function?<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The goal of this function is to copy whatever there in the source to destination, the data which is pointed by the source pointer should not be modified. But if there is any such activity then it will not be reported to the programmer. So, the first method is prone to mistakes.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">That&#8217;s why you can change the prototype of that function.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">The second method is actually the defensive implementation. What you did was, you just mentioned \u2018const\u2019 here.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; 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;\">So, if you just try to do this, then the compiler triggers an error saying that \u201cHey, the data which is pointed by the source should be constant but you are trying to change it\u201d, that&#8217;s a mistake. So, a programmer will be alerted here<\/span><span style=\"font-weight: 400;\">.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; 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;\">A programmer when sees <\/span><span style=\"font-weight: 400; color: #ff0000;\">void copy_src_to_dst(uint8_t *src, uint8_t *dst, uint8_t len)<\/span><span style=\"font-weight: 400;\"> prototype, then there is a possibility that the programmer may change the data which is pointed by the source. Because there is no guard here for the source. He may think that it&#8217;s OK to change the data pointed by the source.&nbsp;<\/span><\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; 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;\">But when the programmer sees <\/span><span style=\"font-weight: 400; color: #ff0000;\">void copy_src_to_dst(uint8_t <strong>const<\/strong> *src, uint8_t *dst, uint8_t len)<\/span><span style=\"font-weight: 400;\"> prototype, then he clearly understands that the data pointed by the source should not be modified. That&#8217;s why I would always go with this implementation. I mean the code implementation is the same, but the prototype implementation is different here. So, that&#8217;s the only difference compared to this implementation.<\/span><\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">You can see the data guarding or pointer guarding in all your professional code implementations.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">For example, consider the prototype of an open system call in Linux.<\/span><\/p>\n<figure id=\"attachment_12264\" aria-describedby=\"caption-attachment-12264\" style=\"width: 592px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-12264\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/11\/Figure-5.png\" alt=\"const in C\" width=\"592\" height=\"334\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-5.png 1441w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-5-300x169.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-5-1024x578.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-5-768x433.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-5-600x339.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-5-200x113.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-5-400x226.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-5-800x451.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-5-1200x677.png 1200w\" sizes=\"(max-width: 592px) 100vw, 592px\" \/><figcaption id=\"caption-attachment-12264\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. open(3) &#8211; Linux man page<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Now, you can see that the <span style=\"color: #ff0000;\">const char *path<\/span> is a case of modifiable pointer and constant data.&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">This is a prototype of the write() system call.<\/span><\/p>\n<figure id=\"attachment_12265\" aria-describedby=\"caption-attachment-12265\" style=\"width: 518px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-12265\" src=\"http:\/\/fastbitlab.com\/wp-content\/uploads\/2022\/11\/Figure-6.png\" alt=\"const usage and different case studies in C\" width=\"518\" height=\"335\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-6.png 1223w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-6-300x194.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-6-1024x662.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-6-768x497.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-6-600x388.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-6-200x129.png 200w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-6-400x259.png 400w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-6-800x517.png 800w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-6-1200x776.png 1200w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><figcaption id=\"caption-attachment-12265\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. write(2)- Linux man page<\/span><\/figcaption><\/figure>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span class=\"\" style=\"font-weight: 400; color: #800000; border-width: 0px; font-family: Oswald;\" data-font-family=\"Oswald\" data-font-weight=\"400\" data-font-style=\"\">What write() system call does?&nbsp;<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Writes up to count bytes from buffer to file referred by the file descriptor. Buffer is given by the user, that&#8217;s user data. So, user data has to be constant. The implementation should not modify that. That&#8217;s why it is guarded with const.<\/span><\/p>\n<p class=\"\" style=\"font-size: 17px; line-height: 1.8em; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"font-weight: 400; color: #000000;\">Hope you understood the use case scenarios and use const generously wherever you find the chance to use it. And in the following article, let&#8217;s understand Case 3. Case 3 is modifiable data and a constant pointer.<\/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: #0000ff;\"><strong><span style=\"color: #993366;\">Get Microcontroller Embedded C Programming Full course on<\/span><\/strong> <a style=\"color: #0000ff;\" href=\"https:\/\/www.udemy.com\/course\/microcontroller-embedded-c-programming\/\">Here<\/a>.<\/span><\/p>\n<p class=\"\" style=\"font-size: 20px; border-width: 0px; 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=\"font-size: 17px; border-width: 0px;\"><span style=\"color: #000000;\">C<span style=\"font-weight: 400;\">lick here:<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; &#8216;const&#8217; usage and different case studies &nbsp; &nbsp; &nbsp; In this article, let&#8217;s understand const pointer and will go through a different case study involving const with pointer. &nbsp; The first case is&nbsp; constant data. &nbsp; uint8_t const data = 50 is a case of constant data.&nbsp; What are the use cases of this? [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":12260,"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":"enable","ocean_disable_heading":"default","ocean_post_title":"'const' usage and different case studies","ocean_post_subheading":"","ocean_post_title_style":"solid-color","ocean_post_title_background_color":"#1ca08f","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-12257","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>&#039;const&#039; keyword Usage: Exploring Case Studies and Best Practices<\/title>\n<meta name=\"description\" content=\"Explore the versatile applications of the &#039;const&#039; keyword in programming through real-world case studies. Learn how &#039;const&#039; ensures data\" \/>\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-const-usage-and-different-case-studies-pointer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"&#039;const&#039; keyword Usage: Exploring Case Studies and Best Practices\" \/>\n<meta property=\"og:description\" content=\"Explore the versatile applications of the &#039;const&#039; keyword in programming through real-world case studies. Learn how &#039;const&#039; ensures data\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/\" \/>\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-11-12T05:09:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-20T09:22:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1841\" \/>\n\t<meta property=\"og:image:height\" content=\"877\" \/>\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-const-usage-and-different-case-studies-pointer\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Microcontroller Embedded C Programming Lecture 131 | &#8216;const&#8217; usage and different case studies\",\"datePublished\":\"2022-11-12T05:09:21+00:00\",\"dateModified\":\"2023-09-20T09:22:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/\"},\"wordCount\":981,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/Figure-1-3.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-const-usage-and-different-case-studies-pointer\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/\",\"name\":\"'const' keyword Usage: Exploring Case Studies and Best Practices\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/Figure-1-3.png\",\"datePublished\":\"2022-11-12T05:09:21+00:00\",\"dateModified\":\"2023-09-20T09:22:26+00:00\",\"description\":\"Explore the versatile applications of the 'const' keyword in programming through real-world case studies. Learn how 'const' ensures data\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/Figure-1-3.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/11\\\/Figure-1-3.png\",\"width\":1841,\"height\":877,\"caption\":\"Figure 1. Case 1: Constant data\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microcontroller Embedded C Programming Lecture 131 | &#8216;const&#8217; usage and different case studies\"}]},{\"@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":"'const' keyword Usage: Exploring Case Studies and Best Practices","description":"Explore the versatile applications of the 'const' keyword in programming through real-world case studies. Learn how 'const' ensures data","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-const-usage-and-different-case-studies-pointer\/","og_locale":"en_US","og_type":"article","og_title":"'const' keyword Usage: Exploring Case Studies and Best Practices","og_description":"Explore the versatile applications of the 'const' keyword in programming through real-world case studies. Learn how 'const' ensures data","og_url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2022-11-12T05:09:21+00:00","article_modified_time":"2023-09-20T09:22:26+00:00","og_image":[{"width":1841,"height":877,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3.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-const-usage-and-different-case-studies-pointer\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Microcontroller Embedded C Programming Lecture 131 | &#8216;const&#8217; usage and different case studies","datePublished":"2022-11-12T05:09:21+00:00","dateModified":"2023-09-20T09:22:26+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/"},"wordCount":981,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3.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-const-usage-and-different-case-studies-pointer\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/","url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/","name":"'const' keyword Usage: Exploring Case Studies and Best Practices","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3.png","datePublished":"2022-11-12T05:09:21+00:00","dateModified":"2023-09-20T09:22:26+00:00","description":"Explore the versatile applications of the 'const' keyword in programming through real-world case studies. Learn how 'const' ensures data","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2022\/11\/Figure-1-3.png","width":1841,"height":877,"caption":"Figure 1. Case 1: Constant data"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-const-usage-and-different-case-studies-pointer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Microcontroller Embedded C Programming Lecture 131 | &#8216;const&#8217; usage and different case studies"}]},{"@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\/12257","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=12257"}],"version-history":[{"count":5,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/12257\/revisions"}],"predecessor-version":[{"id":16024,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/12257\/revisions\/16024"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/12260"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=12257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=12257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=12257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}