Hacker News new | past | comments | ask | show | jobs | submit login

strto*() is the wrong API to use if you care about errors.

  char* forty_two = 42;
  int i;
  if (sscanf (forty_two, "%d", &i) != 1) {
      /* error */
  }
Sometimes, there's more than one way to skin a cat, and one of them is more suited to the task at hand.



Now what happens if you pass it a string without a null byte terminator?


I made no claim that using sscanf instead of strto* fixes all the issues with C string represenation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: