title: How to cast a string to a integer
body: <p>I have a 40 digit hex number stored in a string, I have to store it inside a struct called Int40 that only contains a pointer to an int.   </p>
  
  <pre><code> typedef struct Int40    
   {    
      // a dynamically allocated array to hold a 40     
      // digit integer, stored in reverse order    
      int  *digits;    
  } Int40;    
  </code></pre>
  
  <p>this is what I have tried            </p>
  
  <pre><code>Int40 *parseString(char *str)
  {
      Int40 *value = malloc(sizeof(Int40) * MAX40);
      for (int i = 0; i &lt; MAX40; i++)
        {
           value[i] = (int)str[i];
        }
      return value;
  }
  
  int main()
  {
      Int40 *p;
      p = parseString("0123456789abcdef0123456789abcdef01234567");
      printf("-&gt; %d\n", *p);
  }
  </code></pre>
  
  <p>I know that an Int cant contain 40 digits thats why I tried to store each number from the string in an array of integers but my code doesnt seem to work.
  Edit: Also the number contains letters because is a hex number, will I have to the get the ascii value of the hex number to be able to store it in the array of int, how do i do that?</p>