fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7. char *s = "0xaf10 42 0x27C 9952";
  8. int num1,num2, num3, num4;
  9. char *end;
  10.  
  11.  
  12. num1=strtol(s, end, 16);
  13. num2=strtol(end, end, 10);
  14. num3=strtol(end, end, 16);
  15. num4=strtol(end, NULL, 10);
  16. printf("%x\n", num1); // af10
  17. printf("%d\n", num2); // 42
  18. printf("%X\n", num3); // 27C
  19. printf("%d\n", num4); // 9952
  20. return 0;
  21. }
Runtime error #stdin #stdout 0s 2164KB
stdin
Standard input is empty
stdout
Standard output is empty