Timeline for Trying to reimplement GetInt()
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 3, 2017 at 3:41 | comment | added | burningserenity | Awesome! Thanks for the link. | |
Jun 1, 2017 at 3:43 | comment | added | chad | You can look at the actual library to see how it works at github.com/cs50/libcs50 | |
May 17, 2017 at 3:00 | comment | added | burningserenity | Thanks. I checked out the man page, and it says that errno will never be zero. Doesn't strtol return 0 on an error, though? That was what I had to work around by intentionally setting x to a number outside INT_MAX. This is intriguing, but I'm having a hard time wrapping my head around it. | |
Apr 30, 2017 at 22:51 | history | edited | chad | CC BY-SA 3.0 |
deleted 4 characters in body
|
Apr 30, 2017 at 22:45 | comment | added | chad |
You don't declare ERANGE or errno , they are part of errno.h . Run man errno for more information on what it is. With regards to the char* instead of char[] , you are correct, my bad. String literals, unless declared as a char array, are immutable. I updated my answer.
|
|
Apr 30, 2017 at 22:42 | history | edited | chad | CC BY-SA 3.0 |
added 1 character in body
|
Apr 30, 2017 at 16:56 | vote | accept | burningserenity | ||
Apr 30, 2017 at 16:56 | |||||
Apr 29, 2017 at 21:36 | comment | added | burningserenity | Also, why a char* and not a char array? I'm trying to do it that way, but I segfault when fgets tries to store the value from STDIN in the char*. | |
Apr 29, 2017 at 15:09 | comment | added | burningserenity | I've never used errno.h before. How do I declare ERANGE? | |
Apr 28, 2017 at 16:55 | history | answered | chad | CC BY-SA 3.0 |