{"id":13784,"date":"2023-02-01T10:32:18","date_gmt":"2023-02-01T05:02:18","guid":{"rendered":"https:\/\/fastbitlab.com\/?p=13784"},"modified":"2023-08-19T11:06:58","modified_gmt":"2023-08-19T05:36:58","slug":"microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array","status":"publish","type":"post","link":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/","title":{"rendered":"Microcontroller Embedded C Programming Lecture 171| Read-Write operation on an array"},"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: 40px; 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=\"font-size: 30px; border-width: 0px; line-height: 50px; font-family: 'Roboto Slab'; font-weight: 400; margin-top: 10px; text-align: center;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><strong><span style=\"color: #000080;\">Read-Write operation on an array<\/span><\/strong><\/h1>\n<div class=\"row bg-editor-hr-wrap\" style=\"border-width: 0px;\">\n<div class=\"col-lg-12 col-md-12 col-xs-12 col-sm-12\">\n<div>\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=\"border-width: 0px; font-size: 25px; line-height: 29px; 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;\"><b>Read and write to an array<\/b><\/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;\">Write a program that initializes an array of 10 items to 0xff and then prints the values of each element.<\/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 this article, we are learning array initialization and array read and write.<\/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;\">Create an array of 10 data items of type uint8_t.<\/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: #800080;\"><b>uint8_t someData[10];&nbsp;<\/b><\/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 initialize all the data items present in this array. There are several ways to do this. You can initialize this array during the variable definition itself.&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;\">So, you have to give the assignment operator(=) and you have to use curly braces, and here you can initialize the individual data items.<\/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: #800080;\"><b>uint8_t someData[10] = {0xff, 0xff, 0xff};&nbsp;<\/b><\/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 I just initialized the first 3 data items of the array to 0xff. This is perfectly fine.&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;\">But, what happens to the remaining data items?<\/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 remaining data items will be automatically initialized to value zeros. That is a very important point.<\/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;\"><b><span style=\"color: #800080;\">uint8_t someData[10] = {0xff,0xff,0xff,0,0,0,0,0,0,0};<\/span> <span style=\"color: #008000;\">\/\/<\/span><\/b><span style=\"font-weight: 400; color: #008000;\"> This is equivalent to above code.<\/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;\">So, if you just partially initialize the array, then all remaining data items will be automatically initialized to zeros.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\"><span style=\"color: #ff99cc;\">#include<\/span>&lt;stdio.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span>&lt;stdint.h&gt;\r\n\r\n<span style=\"color: #ff99cc;\">int<\/span> main(<span style=\"color: #ff99cc;\">void<\/span>)\r\n{\r\n    <span style=\"color: #008000;\">uint8_t<\/span> someData[10] = {0xff,0xff,0xff};\r\n\r\n    <span style=\"color: #ff99cc;\">return<\/span> 0;\r\n}<\/pre>\n<p class=\"\" style=\"text-align: center;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\">Array declaration<\/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: #ff0000;\">What happens if I remove the number of data item&#8217;s information?<\/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: #800080;\"><b>uint8_t someData[] = {0xff,0xff,0xff};&nbsp;<\/b><\/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: #ff0000;\">Do you think this is a legal &#8216;C&#8217; statement?&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;\">Of course, it is. By using the initializer or initialization information, you are giving enough information for the compiler to calculate the size of the array.<\/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 during the compilation, the compiler will automatically calculate the size of the array by looking at the information of the initialization.<\/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;\">Here you are looking to initialize 3 data items. The compiler will consider that this array is of three data items. That&#8217;s perfectly fair.&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;\">That&#8217;s why, when you do array definition and initialization in one go, then you can drop a number of data items information, that will be automatically tuned.&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=\"color: #000000;\"><span style=\"color: #800080;\"><b>uint8_t someData[ ];<\/b><\/span><span style=\"font-weight: 400; color: #008000;\"> \/\/ But this is wrong.<\/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;\">If I leave without initializing the array, then this would be an error. Because the compiler couldn&#8217;t able to calculate the array size during compile time.&nbsp;<\/span><\/p>\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;\">Let&#8217;s understand one more type of array declaration or array definition.&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;\">Look at the below code snippet, you have the array definition.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #ff99cc;\">#include<\/span>&lt;stdio.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span>&lt;stdint.h&gt;\r\n\r\n<span style=\"color: #ff99cc;\">int<\/span> main(<span style=\"color: #ff99cc;\">void<\/span>)\r\n{\r\n    <span style=\"color: #ff99cc;\">int<\/span> len = 10;\r\n    <span style=\"color: #008000;\">uint8_t<\/span> someData[len];\r\n    <span style=\"color: #ff99cc;\">return<\/span> 0;\r\n}<\/pre>\n<p class=\"\" style=\"text-align: center;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"color: #000000;\">Array declaration<\/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 created a variable int len = 10;&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;\">This information need not be a constant, it can be a variable. That&#8217;s why, I removed the 10 and in the place of 10 I mentioned the variable name \u2018len\u2019, so this type of array is called a variable length array(VLA).<\/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;\">This syntax is introduced as a C99 standard onwards. So, this wasn&#8217;t there in a C90 or NCC standard.<\/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 learned how to initialize an array.<\/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 look at how to read and write to individual array elements.<\/span><\/p>\n<figure id=\"attachment_13789\" aria-describedby=\"caption-attachment-13789\" style=\"width: 572px\" class=\"wp-caption aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-13789 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-3-12.png\" alt=\"Figure 3. Read and write to an array\" width=\"572\" height=\"291\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12.png 1725w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12-300x153.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12-1024x521.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12-768x390.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12-600x305.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12-1536x781.png 1536w\" sizes=\"(max-width: 572px) 100vw, 572px\" \/><figcaption id=\"caption-attachment-13789\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 1. Read and write to an array<\/span><\/figcaption><\/figure>\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;\">Here, 0XFF are the array elements.&nbsp; 0xE005, 0XE006,..0XE00E are the contiguous memory location addresses, and someData is the base pointer or a reference.<\/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;\">Write a new value to the array element 2.&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=\"color: #ff0000;\"><b>How do you identify the array element 2 in this case?&nbsp;<\/b><\/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;\">0xE006 is the array element 2.&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=\"color: #ff0000;\"><b>How do you write a new value to the array element 2?&nbsp;<\/b><\/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 just increment the pointer. Let&#8217;s say <\/span><b>someData+1<\/b><span style=\"font-weight: 400;\">.<\/span><span style=\"font-weight: 400;\">&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;\">So, if you do that it will start pointing 0xE006, and then dereference this whole value, and then write a new value, let&#8217;s say 0x9.&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=\"color: #800080;\"><b>*(someData + 1) = 0x9;<\/b><\/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;\">If we do this much, then a new value will be stored in the second element. That&#8217;s a procedure.<\/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;\">So, by holding the base pointer so you can access any location of the array.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\"><span style=\"color: #ff99cc;\">#include<\/span>&lt;stdio.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span>&lt;stdint.h&gt;\r\n\r\n<span style=\"color: #ff99cc;\">int<\/span> main(<span style=\"color: #ff99cc;\">void<\/span>)\r\n{\r\n    <span style=\"color: #008000;\">uint8_t<\/span> someData[10] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};\r\n   <span style=\"color: #ff00ff;\"> printf<\/span>(\"Before: 2nd data item = %x\\n\", *(someData+1));\r\n    *(someData+1) = 0x9;\r\n    <span style=\"color: #ff00ff;\">printf<\/span>(\"After: 2nd data item = %x\\n\", *(someData+1));\r\n   <span style=\"color: #ff99cc;\"> return<\/span> 0;\r\n}<\/pre>\n<div><span class=\"\" style=\"font-weight: 400; box-shadow: #cecece 0px 0px 0px 0px;\">Now, let&#8217;s try this.<\/span><\/div>\n<div><\/div>\n<div><\/div>\n<figure id=\"attachment_13790\" aria-describedby=\"caption-attachment-13790\" style=\"width: 648px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-13790 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-4-9.png\" alt=\"Figure 4. Code and Output \" width=\"648\" height=\"353\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-4-9.png 1425w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-4-9-300x164.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-4-9-1024x558.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-4-9-768x419.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-4-9-600x327.png 600w\" sizes=\"(max-width: 648px) 100vw, 648px\" \/><figcaption id=\"caption-attachment-13790\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 2. Output<\/span><\/figcaption><\/figure>\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, I initialized the array to 0xff.&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;\">And after that base pointer+1 (someData+1), and reference that(*), I wrote the new value 0x9.<\/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;\">Use printf to print the value of the second data item. To access the second element, you can use pointer manipulation. So, *(someData+1) gives us the value of the second data item.<\/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;\">And let&#8217;s print once again here, printf(\u201cAfter: 2nd data item = %x\\n\u201d,*(someData+1));<\/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;\">Look at the output here, before the second data item was ff, and after the second data item was 9. Here you modified the second data item using the reference.&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;\">So, you just incremented the reference to the next position, and you just dereferenced that and you stored a new 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=\"font-weight: 400; color: #000000;\">But accessing array elements like this would be a tedious process.<\/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;\">There is a shortcut actually. The shorthand method is, just to use the array name someData and after that open the square brackets, and after that mention the offset.<\/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: #800080;\"><b>someData[1] = 0x9;&nbsp;<\/b><\/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;\">Here 1 is an offset to access the second element. So, we mentioned the offset and the value.&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;\">*(someData +1) = 0x9 and someData[1]=0x9, both statements are identical.&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;\">This is just for your convenience during programming. So, when you write like someData[1]=0x9 it will be internally converted to *(someData +1) = 0x9 by the compiler.&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;\">So, to modify the first data element you should be doing like someData[0]= 0x1. So, that&#8217;s the reason why we say array indexing starts from zero. The real reason lies in the pointer manipulation method.&nbsp; The compiler sees this method like *(someData[0])=0x1;&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;\">That&#8217;s why we always index the array elements from 0.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<figure id=\"attachment_13791\" aria-describedby=\"caption-attachment-13791\" style=\"width: 646px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"wp-image-13791 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-5-6.png\" alt=\"Figure 5. Array Indexing\" width=\"646\" height=\"285\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-5-6.png 1839w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-5-6-300x132.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-5-6-1024x452.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-5-6-768x339.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-5-6-600x265.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-5-6-1536x677.png 1536w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><figcaption id=\"caption-attachment-13791\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 3. Array Indexing<\/span><\/figcaption><\/figure>\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;\">The first data item we call the 0 elements of the array. The next data item we call the first data element of the array. That&#8217;s why we can use this notation someData[ i ], where \u2018i\u2019 ranges from 0 to 9.&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;\">So, by doing this we can access different data elements or different data items of the array.&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;\">So, now let&#8217;s do some experiments.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"box-shadow: #cecece 0px 0px 0px 0px inset; font-size: 12px;\"><span style=\"color: #ff99cc;\">#include<\/span>&lt;stdio.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span>&lt;stdint.h&gt;\r\n\r\n<span style=\"color: #ff99cc;\">int<\/span> main(<span style=\"color: #ff99cc;\">void<\/span>)\r\n{\r\n<span style=\"color: #008000;\">    uint8_t<\/span> someData[10] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};\r\n\r\n    <span style=\"color: #ff00ff;\">printf<\/span>(\"0th element value = %x\\n\", someData[0]);\r\n   <span style=\"color: #ff00ff;\"> printf<\/span>(\"0th element value = %x\\n\", *someData+0));\r\n    <span style=\"color: #ff99cc;\">return<\/span> 0;\r\n}\r\n\r\n<\/pre>\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=\"font-weight: 400; color: #000000;\">In printf statements you used both methods. Both those statements are identical.<\/span><\/p>\n<p class=\"\" style=\"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;\">Now let&#8217;s check the output, both are the same. It gives the 0th element value = ff.(Figure 4)<\/span><\/p>\n<figure id=\"attachment_13792\" aria-describedby=\"caption-attachment-13792\" style=\"width: 547px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-13792 \" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-6-4.png\" alt=\"Figure 6. Code and Output\" width=\"547\" height=\"303\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-6-4.png 1315w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-6-4-300x166.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-6-4-1024x568.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-6-4-768x426.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-6-4-600x333.png 600w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/><figcaption id=\"caption-attachment-13792\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 4. Output<\/span><\/figcaption><\/figure>\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=\"\">&nbsp;<\/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: #ff0000;\"><b>What if we want to print the values of all the elements of this array?<\/b><\/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;\">&nbsp;<span style=\"color: #000000;\">In that case, you can print element by element no problem, but it&#8217;s better to use a loop here.&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;\">Now, let&#8217;s use a while loop, or for loop to print values of all the data elements of this array.<\/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;\">So, for that let me write the printf contents of this array. So, let&#8217;s use it for loop.&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=\"color: #800080;\"><b>for(uint32_t i=0; i&lt;10; i++)<\/b><\/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;\">Create a variable to index into the array. So, let&#8217;s create a variable uint32_t i. Initialize that i=0. For this array index can go from 0 to 9, that&#8217;s why, let me use i &lt; 10, and after that i++.<\/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;\">Now here let&#8217;s use one more printf, printf(&#8220;%x\\t\u201d, someData[i]&#8221;); I print all the values in one line, so I would give \\t and after that someData[i].<\/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;\">This would print the values of all the data items of the array, where \u2018i\u2019 ranges from 0 to 9. <\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\"><span style=\"color: #ff99cc;\">#include<\/span>&lt;stdio.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span>&lt;stdint.h&gt;\r\n\r\n<span style=\"color: #ff99cc;\">int<\/span> main(<span style=\"color: #ff99cc;\">void<\/span>)\r\n{\r\n<span style=\"color: #008000;\">   uint8_t<\/span> someData[10] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};\r\n\r\n<span style=\"color: #ff00ff;\">   printf<\/span>(\"contents of this array\\n\");\r\n\r\n<span style=\"color: #ff99cc;\">   for<\/span>(<span style=\"color: #008000;\">uint32_t<\/span> i = 0 ; i &lt; 10 ; i++)\r\n   {\r\n<span style=\"color: #ff00ff;\">        printf<\/span>(\"%x\\t\",someData[i]);\r\n   }\r\n\r\n<span style=\"color: #ff99cc;\">   return<\/span> 0;\r\n}<\/pre>\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&nbsp; is shown in Figure 5.<\/span><\/p>\n<figure id=\"attachment_13793\" aria-describedby=\"caption-attachment-13793\" style=\"width: 528px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-13793\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-7-2.png\" alt=\"Read-Write operation on an array\" width=\"528\" height=\"276\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-7-2.png 1451w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-7-2-300x157.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-7-2-1024x536.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-7-2-768x402.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-7-2-600x314.png 600w\" sizes=\"(max-width: 528px) 100vw, 528px\" \/><figcaption id=\"caption-attachment-13793\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 5. Code and Output<\/span><\/figcaption><\/figure>\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 modify the second data element.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\"><span style=\"color: #ff99cc;\">#include<\/span>&lt;stdio.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span>&lt;stdint.h&gt;\r\n\r\n<span style=\"color: #ff99cc;\">int<\/span> main(<span style=\"color: #ff99cc;\">void<\/span>)\r\n{\r\n<span style=\"color: #008000;\">    uint8_t<\/span> someData[10] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};\r\n\r\n    <span style=\"color: #ff00ff;\">printf<\/span>(\"contents of this array\\n\");\r\n<span style=\"color: #ff99cc;\">    \r\n   for<\/span>(<span style=\"color: #008000;\">uint32_t<\/span> i = 0 ; i &lt; 10 ; i++)\r\n   {\r\n       <span style=\"color: #ff00ff;\">printf<\/span>(\"%x\\t\",someData[i]);\r\n   }\r\n\r\nsomeData[2] = 0x33;\r\n<span style=\"color: #ff00ff;\">printf<\/span>(\"\\n\");\r\n\r\n<span style=\"color: #ff99cc;\">for<\/span>(<span style=\"color: #008000;\">uint32_t<\/span> i = 0 ; i &lt; 10 ; i++)\r\n{\r\n    <span style=\"color: #ff00ff;\">printf<\/span>(\"%x\\t\",someData[i]);\r\n}\r\n<span style=\"color: #ff99cc;\">return<\/span> 0;\r\n}<\/pre>\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=\"font-weight: 400; color: #000000;\">Array indexing starts from the 0th data element. Here I would use someData[2] = 0x33. The modified second data element is 33. The output shown in Figure 6.&nbsp;<\/span><\/p>\n<figure id=\"attachment_13794\" aria-describedby=\"caption-attachment-13794\" style=\"width: 543px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-13794\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-8-2.png\" alt=\"Read-Write operation on an array\" width=\"543\" height=\"280\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-8-2.png 1473w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-8-2-300x155.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-8-2-1024x528.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-8-2-768x396.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-8-2-600x309.png 600w\" sizes=\"(max-width: 543px) 100vw, 543px\" \/><figcaption id=\"caption-attachment-13794\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 6. Output<\/span><\/figcaption><\/figure>\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=\"\">&nbsp;<\/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;\">So, you can also initialize all the data elements in a loop.<\/span><\/p>\n<pre class=\"color-5-text-contrast color5-background-color\" style=\"font-size: 12px; box-shadow: #cecece 0px 0px 0px 0px inset;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\"><span style=\"color: #ff99cc;\">#include<\/span>&lt;stdio.h&gt;\r\n<span style=\"color: #ff99cc;\">#include<\/span>&lt;stdint.h&gt;\r\n\r\n<span style=\"color: #ff99cc;\">int<\/span> main(<span style=\"color: #ff99cc;\">void<\/span>)\r\n{\r\n<span style=\"color: #008000;\">   uint8_t<\/span> someData[10] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};\r\n\r\n<span style=\"color: #ff00ff;\">   printf<\/span>(\"contents of this array\\n\");\r\n<span style=\"color: #ff99cc;\"> \r\n   for<\/span>(<span style=\"color: #008000;\">uint32_t<\/span> i = 0 ; i &lt; 10 ; i++)\r\n   {\r\n<span style=\"color: #ff00ff;\">        printf<\/span>(\"%x\\t\",someData[i]);\r\n   }\r\n\r\n\r\n<span style=\"color: #ff00ff;\">   printf<\/span>(\"\\n\");\r\n\r\n<span style=\"color: #ff99cc;\">   for<\/span>(<span style=\"color: #008000;\">uint32_t<\/span> i = 0 ; i &lt; 10 ; i++)\r\n   {\r\n     someData[i] = 0x33;\r\n<span style=\"color: #ff00ff;\">     printf<\/span>(\"%x\\t\",someData[i]);\r\n    }\r\n<span style=\"color: #ff99cc;\">    return<\/span> 0;\r\n}<\/pre>\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;\">I would use <span style=\"color: #800080;\">someData[i] = 0x33<\/span>, it prints all the data elements 33.&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;\">So, that&#8217;s how by using the loop and array indexing, so you can initialize an array to different values.&nbsp;<\/span><\/p>\n<figure id=\"attachment_13795\" aria-describedby=\"caption-attachment-13795\" style=\"width: 597px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-13795\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-9-1.png\" alt=\"Read-Write operation on an array\" width=\"597\" height=\"321\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-9-1.png 1439w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-9-1-300x161.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-9-1-1024x550.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-9-1-768x413.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-9-1-600x322.png 600w\" sizes=\"(max-width: 597px) 100vw, 597px\" \/><figcaption id=\"caption-attachment-13795\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 7. Output<\/span><\/figcaption><\/figure>\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;\">That&#8217;s about array indexing, why array index starts from zero, and accessing different data items of the array using pointer manipulation.<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; font-size: 20px; line-height: 30px;\" data-font-family=\"Roboto Slab\" data-font-weight=\"400\" data-font-style=\"\"><span style=\"text-decoration: underline; color: #000080;\"><b>Summary:<\/b><\/span><\/p>\n<figure id=\"attachment_13796\" aria-describedby=\"caption-attachment-13796\" style=\"width: 631px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-13796\" src=\"https:\/\/fastbitlab.com\/wp-content\/uploads\/2023\/01\/Figure-10.png\" alt=\"Read-Write operation on an array\" width=\"631\" height=\"378\" srcset=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-10.png 1541w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-10-300x180.png 300w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-10-1024x613.png 1024w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-10-768x460.png 768w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-10-600x359.png 600w, https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-10-1536x920.png 1536w\" sizes=\"(max-width: 631px) 100vw, 631px\" \/><figcaption id=\"caption-attachment-13796\" class=\"wp-caption-text\"><span style=\"color: #000000;\">Figure 8. Summary<\/span><\/figcaption><\/figure>\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;\">Please note that, *(someData) = 10 is identical to someData[0]=10. *(someData+1) = 20 is identical to someData[1]=20, 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;\">So, this is array manipulation using pointer access.<\/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;\">That&#8217;s about a read and write to an array.&nbsp;<\/span><\/p>\n<p class=\"\">&nbsp;<\/p>\n<p class=\"\" style=\"font-size: 23px; border-width: 0px; font-family: 'Roboto Slab'; font-weight: 400; line-height: 30px;\" 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;\"><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; Read-Write operation on an array &nbsp; Read and write to an array Write a program that initializes an array of 10 items to 0xff and then prints the values of each element. In this article, we are learning array initialization and array read and write. &nbsp; Create an array of 10 data items of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":13789,"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":"Read-Write operation on an array","ocean_post_subheading":"","ocean_post_title_style":"solid-color","ocean_post_title_background_color":"#004691","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-13784","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>Exploring Array Manipulation: Read and Write Operations<\/title>\n<meta name=\"description\" content=\"Microcontroller Embedded C Programming: Read-Write operation on an array. Learn how to initialize, access, and modify array elements efficiently through pointers and indexing.\" \/>\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-171-read-write-operation-on-an-array\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exploring Array Manipulation: Read and Write Operations\" \/>\n<meta property=\"og:description\" content=\"Microcontroller Embedded C Programming: Read-Write operation on an array. Learn how to initialize, access, and modify array elements efficiently through pointers and indexing.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/\" \/>\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=\"2023-02-01T05:02:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-19T05:36:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1725\" \/>\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=\"8 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-171-read-write-operation-on-an-array\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/\"},\"author\":{\"name\":\"FastBitLab\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#\\\/schema\\\/person\\\/e32b38e733a0d76ffa7e6bc998652e5d\"},\"headline\":\"Microcontroller Embedded C Programming Lecture 171| Read-Write operation on an array\",\"datePublished\":\"2023-02-01T05:02:18+00:00\",\"dateModified\":\"2023-08-19T05:36:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/\"},\"wordCount\":1436,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Figure-3-12.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-171-read-write-operation-on-an-array\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/\",\"name\":\"Exploring Array Manipulation: Read and Write Operations\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Figure-3-12.png\",\"datePublished\":\"2023-02-01T05:02:18+00:00\",\"dateModified\":\"2023-08-19T05:36:58+00:00\",\"description\":\"Microcontroller Embedded C Programming: Read-Write operation on an array. Learn how to initialize, access, and modify array elements efficiently through pointers and indexing.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/#primaryimage\",\"url\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Figure-3-12.png\",\"contentUrl\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Figure-3-12.png\",\"width\":1725,\"height\":877,\"caption\":\"Figure 3. Read and write to an array\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/fastbitlab.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microcontroller Embedded C Programming Lecture 171| Read-Write operation on an array\"}]},{\"@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":"Exploring Array Manipulation: Read and Write Operations","description":"Microcontroller Embedded C Programming: Read-Write operation on an array. Learn how to initialize, access, and modify array elements efficiently through pointers and indexing.","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-171-read-write-operation-on-an-array\/","og_locale":"en_US","og_type":"article","og_title":"Exploring Array Manipulation: Read and Write Operations","og_description":"Microcontroller Embedded C Programming: Read-Write operation on an array. Learn how to initialize, access, and modify array elements efficiently through pointers and indexing.","og_url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/","og_site_name":"FastBit EBA","article_publisher":"https:\/\/www.facebook.com\/fastbiteba\/","article_published_time":"2023-02-01T05:02:18+00:00","article_modified_time":"2023-08-19T05:36:58+00:00","og_image":[{"width":1725,"height":877,"url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12.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":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/#article","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/"},"author":{"name":"FastBitLab","@id":"https:\/\/fastbitlab.com\/blog\/#\/schema\/person\/e32b38e733a0d76ffa7e6bc998652e5d"},"headline":"Microcontroller Embedded C Programming Lecture 171| Read-Write operation on an array","datePublished":"2023-02-01T05:02:18+00:00","dateModified":"2023-08-19T05:36:58+00:00","mainEntityOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/"},"wordCount":1436,"commentCount":0,"publisher":{"@id":"https:\/\/fastbitlab.com\/blog\/#organization"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12.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-171-read-write-operation-on-an-array\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/","url":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/","name":"Exploring Array Manipulation: Read and Write Operations","isPartOf":{"@id":"https:\/\/fastbitlab.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/#primaryimage"},"image":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/#primaryimage"},"thumbnailUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12.png","datePublished":"2023-02-01T05:02:18+00:00","dateModified":"2023-08-19T05:36:58+00:00","description":"Microcontroller Embedded C Programming: Read-Write operation on an array. Learn how to initialize, access, and modify array elements efficiently through pointers and indexing.","breadcrumb":{"@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/#primaryimage","url":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12.png","contentUrl":"https:\/\/fastbitlab.com\/blog\/wp-content\/uploads\/2023\/01\/Figure-3-12.png","width":1725,"height":877,"caption":"Figure 3. Read and write to an array"},{"@type":"BreadcrumbList","@id":"https:\/\/fastbitlab.com\/blog\/microcontroller-embedded-c-programming-lecture-171-read-write-operation-on-an-array\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fastbitlab.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Microcontroller Embedded C Programming Lecture 171| Read-Write operation on an array"}]},{"@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\/13784","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=13784"}],"version-history":[{"count":4,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/13784\/revisions"}],"predecessor-version":[{"id":15299,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/posts\/13784\/revisions\/15299"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media\/13789"}],"wp:attachment":[{"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/media?parent=13784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/categories?post=13784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fastbitlab.com\/blog\/wp-json\/wp\/v2\/tags?post=13784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}