fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int* subkeys(char *str) {
  6.  
  7. int i = 0;
  8. int * array = malloc(3*sizeof(int));
  9. for(char* token = strtok(str, " "); i < 3 && token;
  10. token = strtok(NULL, " "))
  11. {
  12. array[i++] = strtol(token,NULL,16);
  13. }
  14. return array;
  15. }
  16.  
  17. int main() {
  18.  
  19. char str[128];
  20. fgets(str, 128, stdin);
  21. int * a = subkeys(str);
  22.  
  23. for(int i = 0; i < 3; ++i)
  24. printf("a[%d] = %4d (0x%02x)\n",i+1,a[i],a[i]);
  25.  
  26. free(a);
  27. }
  28.  
Success #stdin #stdout 0s 5520KB
stdin
   12   FF   1A
stdout
a[1] =   18 (0x12)
a[2] =  255 (0xff)
a[3] =   26 (0x1a)