title: Can't write to the video memory from a function with c++ (OS dev)
body: <p>I want to make a simple function that prints a char to the screen:</p>
  <pre><code>unsigned char *_videoMEM = (unsigned char*)0xb8000;
  int c_pos = 0;
  
  void printf(char c){
      //var 1
      _videoMEM[c_pos++] = (char)c;
      _videoMEM[c_pos++] = 0x0f;
      //var 2
      *((char*)0xb8000 + c_pos++) = c;
      *((char*)0xb8000 + c_pos++) = 0x0f;
      //none of the above work
  }
  </code></pre>
  <p>the function executes (i increment a variable and print it in main()) but it didn't wrote to video memory, when i try to do the same thing but in the main() function it works and idk why or how:</p>
  <p>FULL CODE:</p>
  <pre><code>  unsigned char *_videoMEM = (unsigned char*)0xb8000;
    int c_pos = 0;
    char z = '0';
    void printf(char c){
        _videoMEM[c_pos++] = (char)c;
        _videoMEM[c_pos++] = 0x0f;
    }
    //z+5
    extern &quot;C&quot; void start(){
        printf(z++);
        printf(z++);
        printf(z++);    
        _videoMEM[c_pos++] = z++;
        _videoMEM[c_pos++] = 0x0f;
   }
  
  </code></pre>
  <p>It should print to the screen <code>0123</code> but it prints <code>   3</code></p>