title: How to set a value in a specific byte?
body: <p>I am working with MapViewOfFile() and SharedMemory. I am able to read memory content byte by byte! Now I am wondering, how to set new hex values to a specific byte? Due to my code I was hoping that in my second console.log the hex value 0xffc8 is in cell 83. Unfortunately that is not the case.</p>
  
  <pre><code>// main method 
  FILE * pBuf = (FILE*) MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, BUF_SIZE);
  ...
  int d;
  BYTE dbgByte;
  for(d = 0; d &lt; 86; d++){ 
      dbgByte = *((PBYTE) pBuf + (d));
      printf("DEBUG byte %i hexvalue %hhx \n", d, (char) dbgByte); 
      printf("DEBUG byte %i int %i \n", d, (int) dbgByte); 
  }
  // DEBUG - END
  for(d = 0; d &lt; 86; d++){ 
      if (d == 83){ // 0xffc8 = 200
      BYTE writeByte1;
      writeByte1 = *((PBYTE) pBuf + (d));
      writeByte1 = 0xffc8;
      }
  }
  // DEBUG 2 - START
  for(d = 0; d &lt; 86; d++){ 
      dbgByte = *((PBYTE) pBuf + (d));
      printf("DEBUG byte %i hexvalue %hhx \n", d, (char) dbgByte); 
      printf("DEBUG byte %i int %i \n", d, (int) dbgByte); 
  }
  // DEBUG - END
  ...
  </code></pre>
  
  <p>UPDATE: tried Bill's adivce - unfortunately this didn't work as well:</p>
  
  <pre><code>if (d == 84){ // 0x42 = 66
      *((PBYTE) pBuf + (d)) = 0x42;
  }
  </code></pre>
  
  <p>UPDATE-2: tried Captain Oblivious advice - unfortunately the writing-procedure did not work. I am not able see the hex value 42 in my debug-3 logging statement.</p>
  
  <pre><code>for(d = 0; d &lt; 86; d++){ 
      byte = pBuf[d];
      printf("DEBUG-1 ");
      printf("hex:  %hhx; ", byte);
      printf("char:  %c; ", (char) byte);
      printf("dec: %i; ", (int) byte);
      printf(" byte %i; ", d);
      printf("\n");
      if (d == 84){ // 0x42 = 66
          pBuf[d] = 0x42;
          printf("DEBUG-3 ");
          printf("hex:  %hhx; ", byte);
          printf("char:  %c; ", (char) byte);
          printf("dec: %i; ", (int) byte);
          printf(" byte %i; ", d);
          printf("\n");
      }
  }
  </code></pre>