title: String manipulation in C converting a MAC address
body: <p>I have <code>char *MAC="aa:bb:cc:dd:ee:ff:99"</code>.
  In this string all the values are in "hex" format.</p>
  
  <p>How can I store it into another string and remove first two numbers and last four numbers should like this:
  <code>"ss.ttt.uu.vv"</code>.</p>
  
  <p>Here ss is decimal of "cc", ttt is decimal of "dd" likewise.</p>
  
  <pre><code>#define DELIM ":"
  int tok(char *str_to_tokenize)
  {
   // char str_to_tokenize[] = "- Strtok is meant for - breaking up, strings with funny values. + 5";
    char *str_ptr;
  
    fprintf(stdout, "Split \"%s\" into tokens:\n", str_to_tokenize);
  
    str_ptr = strtok(str_to_tokenize, DELIM);
    for(; str_ptr != NULL ;){
      fprintf(stdout, "%s\n", str_ptr);
      str_ptr = strtok(NULL, DELIM);
    }
  
    return 0;
  }
  
  int main()
  {
    char* buffer="aa:bb:c:dd:ee:ff:gg";
    tok(buffer);
    return 0;
  }
  </code></pre>