title: Convert char pointer to unsigned char array
body: <p>I want to convert a char pointer to a unsigned char var, I thought I could do that with just casting but it doesn't work:</p>
  
  <pre><code>char * pch2;
  //Code that puts something in pc2
  part1 = (unsigned char) pch2;
  </code></pre>
  
  <p>I've the code to this:</p>
  
  <pre><code>result.part1 = (unsigned char *) pch2;
  printf("STRUCT %s\n",result.part1);
  </code></pre>
  
  <p>result is just a struct with unsigned char arrays.</p>
  
  <p>EDIT:</p>
  
  <pre><code>            pch2 = strtok( ip, "." );
  
              while( pch2 != NULL ){
                  printf( "x %d x: %s\n", i, pch2 );
                  pch2[size-1] = '\0';
  
                  if(i == 1)
                      result.part1 = (unsigned char *) pch2;
                  if(i == 2)
                      result.part2 = (unsigned char *) pch2;
                  if(i == 3)
                      result.part3 = (unsigned char *) pch2;
                  if(i == 4)
                      result.part4 = (unsigned char *) pch2;
                  i++;
                  pch2 = strtok (NULL,".");
              }   
              printf("STRUCT %c\n",result.part1);
  </code></pre>
  
  <p>Struct:</p>
  
  <pre><code>typedef struct
  {
      unsigned char part1;
      unsigned char part2;
      unsigned char part3;
      unsigned char part4;
  } res;
  </code></pre>