Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double from_str_to_double(const char s[125]) {
- if (s[0] == '-') {
- printf("%s", "It's a SHOP!!! Should be positive! EVERETHING\n");
- return -1;
- }
- int i = 0, sum = 0;
- while (s[i] != '\0') {
- if (s[i] <= '9' && s[i] >= '0' && sum < INT_MAX / 100) {
- sum = sum * 10 + (s[i] - '0');
- i++;
- } else {
- printf("%s", "Should be NUMBER!\n");
- return -1;
- }
- }
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement