title: Trouble Understanding sprintf with 'char * str + int'
body: <p>I was looking at a project and came across the following code and am unable to figure out what the <a href="http://www.cplusplus.com/reference/cstdio/sprintf/" rel="nofollow noreferrer">sprintf</a> is doing in this context and was hoping someone might be able to help me figure it out.</p>
  
  <pre><code>char storage[64];
  int loc = 0;
  int size = 35;
  
  sprintf(storage+(loc),"A");  //Don't know what this does
  loc+=1;
  sprintf(storage+(loc),"%i", size);  //Don't know what this does
  loc+=4;
  sprintf(storage+(loc), "%i", start); //Don't know what this does
  
  start += size;
  loc += 3;
  </code></pre>
  
  <p>The code later does the following in another part</p>
  
  <pre><code>string value;
  int actVal;
  int index = 0;
  for(int j = index+1; j &lt; index+4; j++)
  {
      value += storage[j]; 
  }
  istringstream iss;
  iss.str(value);
  iss &gt;&gt; actVal; //Don't understand how this now contains size
  </code></pre>
  
  <p>The examples I have seen online regarding sprintf never covered that the above code was possible, but the program executes fine. I just can't figure out how the "+loc" affects storage in this instance and how the values would be saved/stored. Any help would be appreciated.</p>