strtod.c 413 B

1234567891011121314151617
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. int main(void) {
  4. char* endptr = 0;
  5. double d;
  6. char* inputs[] = {
  7. "a 1 hello", " 1 hello", "1 hello 2",
  8. "10.123", "010.123", "-5.3",
  9. "0x10.123", "0x1.23", "0x3.21"
  10. };
  11. for (int i = 0; i < sizeof(inputs) / sizeof(char*); i += 1) {
  12. d = strtod(inputs[i], &endptr);
  13. printf("d: %f Endptr: \"%s\"\n", d, endptr);
  14. }
  15. }