atoi doesn't handle underflow/overflow, among others.
strtol contains sophisticated and powerful parsing of numbers. Probably better than your own. Plus it's only a few lines. Much fewer than your solution. I'd say those are the advantages.
That pretty much sums it up.Quote:
I am totally unfirmilliar with errno though if I remember I read something about that a few days ago. I would have to #include <errno.h> and then on a failure return code from strol check the value that is in errno for what type of error it was correct? This would be only necessary if I were going to do something specific after an error. Otherwise I could just force reentry of the data on an error from strol and then checking errno would be unnecessary.