Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
char buff [25];
char *end_ptr;
long sl;

fgets(buff, sizeof (buff), stdin);

errno = 0;

sl = strtol(buff, &end_ptr, 10);

if (ERANGE == errno) {
  puts("number out of range\n");
}
else if (end_ptr == buff) {
  puts("not valid numeric input\n");
}
else if ('\0' != *end_ptr) {
  puts("extra characters on input line\n");
}

...