title: Create a string from uint32/16_t and then parse back the original numbers
body: <p>I need to put into a char* some uint32_t and uint16_t numbers. Then I need to get them back from the buffer.</p>
  
  <p>I have read some questions and I've tried to use sprintf to put them into the char* and sscanf get the original numbers again. However, I'm not able to get them correctly.</p>
  
  <p>Here's an example of my code with only 2 numbers. But I need more than 2, that's why I use realloc. Also, I don't know how to use sprintf and sscanf properly with uint16_t</p>
  
  <pre><code>uint32_t gid = 1100;
  uint32_t uid = 1000;
  char* buffer = NULL;
  uint32_t offset = 0;
  
  buffer = realloc(buffer, sizeof(uint32_t));
  sprintf(buffer, "%d", gid);
  offset += sizeof(uint32_t);
  
  buffer = realloc(buffer, sizeof(uint32_t) + sizeof(buffer));
  sprintf(buffer+sizeof(uint32_t), "%d", uid);
  
  uint32_t valorGID;
  uint32_t valorUID;
  
  sscanf(buffer, "%d", &amp;valorGID);
  buffer += sizeof(uint32_t);
  sscanf(buffer, "%d", &amp;valorUID);
  
  printf("ValorGID %d ValorUID %d \n", valorGID, valorUID);
  </code></pre>
  
  <p>And what I get is</p>
  
  <pre><code>ValorGID 11001000 ValorUID 1000 
  </code></pre>
  
  <p>What I need to get is</p>
  
  <pre><code>ValorGID 1100 ValorUID 1000
  </code></pre>
  
  <p>I am new in C, so any help would be appreciated.</p>