title: How to convert char ASCII to hex equivilent in C?
body: <p>So basically, I am writing code to control an LCD via a micro-controller. (atmega 32) I have the following in my main method: </p>
  
  <pre><code>unsigned char str1[9] = "It Works!";
  sendString(str1);
  </code></pre>
  
  <p>and here is my sendString method:</p>
  
  <pre><code>// Converts each char to hex and sends to LCD
  void sendString(unsigned char *string){ 
  
  
      sendCommand(0x01); // Clear screen 0x01 = 00000001
      _delay_ms(2);
      sendCommand(0x38); // Put in 8-bit mode
      _delay_us(50);
      sendCommand(0b0001110); // LCD on and set cursor off
      _delay_us(50);
  
      //For each char in string, write to the LCD
      for(int i = 0; i &lt; sizeof(string); i++){
          convertASCIIToHex(string[i]);
      }
  }
  </code></pre>
  
  <p>Then the sendString method needs to convert each char. Here is what I have so far:</p>
  
  <pre><code>unsigned int convertASCIIToHex(unsigned char *ch)
  {
      int hexEquivilent[sizeof(ch)] = {0};
  
      for(int i = 0; i &lt; sizeof(ch); i++){
          // TODO - HOW DO I CONVERT FROM CHAR TO HEX????
      }
  
      return hexEquivilent;
   }
  </code></pre>
  
  <p>So how would i go about doing the conversion? I am completely new to C and am learning slowly. I have a feeling I am going about this all wrong as I read somewhere that a char is actually stored as an 8 bit int anyway. How can I get my method to return the HEX value for each input char? </p>