From 629d52b1262879a346e9ca17567a8f483c60ba0a Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 13 Apr 2020 09:18:30 +0200 Subject: Fixed cpp00/ex01 --- cpp00/ex01/utils.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cpp00/ex01/utils.cpp (limited to 'cpp00/ex01/utils.cpp') diff --git a/cpp00/ex01/utils.cpp b/cpp00/ex01/utils.cpp new file mode 100644 index 0000000..27c7daa --- /dev/null +++ b/cpp00/ex01/utils.cpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* utils.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 07:31:30 by charles #+# #+# */ +/* Updated: 2020/04/13 08:43:18 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "utils.hpp" + +int getInt() +{ + std::string s; + int tmp; + + std::cin >> s; + for (size_t i = 0; i < s.length(); i++) + if (!isdigit(s[i])) + return (-1); + std::istringstream(s) >> tmp; + return tmp; +} -- cgit