diff --git a/cpp09/ex02/main.cpp b/cpp09/ex02/main.cpp index 9748723..366c4ee 100644 --- a/cpp09/ex02/main.cpp +++ b/cpp09/ex02/main.cpp @@ -6,17 +6,39 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/05/01 14:45:40 by rparodi #+# #+# */ -/* Updated: 2025/05/01 16:28:50 by rparodi ### ########.fr */ +/* Updated: 2025/05/02 16:06:17 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "PmergeMe.hpp" +#include #include +int check_input(int argc, char **argv) { + for (size_t i = 1; i < static_cast(argc); i++) { + for (size_t j = 0; argv[i][j]; j++) { + if (!std::isdigit(argv[i][j])) + return (i); + } + } + return (0); +} + int main(int argc, char **argv) { if (DEBUG) std::cerr << CLR_MAGENTA << "Warning: DEBUG_MODE is now enable" << CLR_RESET << std::endl << std::endl; if (argc < 2) std::cerr << CLR_RED << "Usage:\t" << argv[0] << " ..." << CLR_RESET << std::endl; + else { + if (DEBUG) { + std::cerr << CLR_CYAN << "Info: " << argv[0] << " have " << argc - 1 << " arguments !" << CLR_RESET << std::endl << std::endl; + } + int check = check_input(argc, argv); + if (check) { + std::cerr << CLR_RED << "Error: I only have to have number in parameter (args: " << check << ")" << CLR_RESET << std::endl; + if (DEBUG) + std::cerr << CLR_MAGENTA << "\tValue of args: [" << argv[check] << "]" << CLR_RESET << std::endl; + } + } return (0); }