diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-12-11 12:11:50 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-12-11 12:11:50 +0100 |
| commit | c10aa969c60cedef893146307fa319250901465a (patch) | |
| tree | e3dfa785191047ee8e2ed533f963fe7c5cd7aacf /cpp06 | |
| parent | 6169d697a5be59426d034b878bffc848de49491d (diff) | |
| download | piscine_cpp-c10aa969c60cedef893146307fa319250901465a.tar.gz piscine_cpp-c10aa969c60cedef893146307fa319250901465a.tar.bz2 piscine_cpp-c10aa969c60cedef893146307fa319250901465a.zip | |
Fixing cpp04 according to correction
Diffstat (limited to 'cpp06')
| -rw-r--r-- | cpp06/ex00/main.cpp | 101 |
1 files changed, 15 insertions, 86 deletions
diff --git a/cpp06/ex00/main.cpp b/cpp06/ex00/main.cpp index ec30bb8..b82c106 100644 --- a/cpp06/ex00/main.cpp +++ b/cpp06/ex00/main.cpp @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/16 10:54:10 by charles #+# #+# */ -/* Updated: 2020/11/11 09:21:08 by cacharle ### ########.fr */ +/* Updated: 2020/11/18 15:53:33 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,91 +16,20 @@ int main(int argc, char **argv) { - if (argc != 2) - { - std::cerr << "Usage: " << argv[0] << " litteral" << std::endl; - return 1; - } - - - std::string s(argv[1]); - - if (s.empty()) - { - std::cerr << "Cannot be empty" << std::endl; - return 1; - } - - bool negative = false; - if (s[0] == '-' || s[0] == '+') - { - if (s[0] == '-') - negative = true; - s.erase(0, 1); - } - - char c; - int i; - float f; - double d; - - if (s == "nan" || s == "inf") - { - d = s == "nan" ? NaN : inf; - if (negative) - d = -d; - f = static_cast<float>(d); - i = static_cast<int>(d); - c = static_cast<char>(d); - } - if (s == "nanf" || s == "inff") - { - f = s == "nanf" ? NaN : inff; - if (negative) - f = -f; - d = static_cast<double>(f); - i = static_cast<int>(f); - c = static_cast<char>(f); - } - - if (isdigit(s[0])) - { - std::stringstream ss(s); - - if (s.find(".") == -1) - { - ss >> i; - d = static_cast<double>(i); - f = static_cast<float>(i); - c = static_cast<char>(i); - } - else if (s.find("f") != -1) - { - ss >> f; - d = static_cast<double>(f); - i = static_cast<int>(f); - c = static_cast<char>(f); - } - else - { - ss >> d; - f = static_cast<float>(d); - i = static_cast<int>(d); - c = static_cast<char>(d); - } - } - else if (!negative && s.length == 1) - { - c = s[0]; - d = static_cast<double>(c); - f = static_cast<float>(c); - i = static_cast<int>(c); - } - else - { - std::cout << "Parsing error" << std::endl; - return 1; - } + // if (argc != 2) + // { + // std::cerr << "Usage: " << argv[0] << " litteral" << std::endl; + // return 1; + // } + // + // + // std::string s(argv[1]); + // + // if (s.empty()) + // { + // std::cerr << "Cannot be empty" << std::endl; + // return 1; + // } return 0; |
