strtod.c 440 B

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