diff --git a/d06/ex00/convert b/d06/ex00/convert new file mode 100755 index 0000000..c0be9d2 Binary files /dev/null and b/d06/ex00/convert differ diff --git a/d06/ex00/main.cpp b/d06/ex00/main.cpp index 41b6c1e..5b5ffae 100644 --- a/d06/ex00/main.cpp +++ b/d06/ex00/main.cpp @@ -15,6 +15,8 @@ int main(int ac, char **av) { return 0; } + std::cout << "\n\n" B_GREEN "----------------------------------------------------\n" + << "\nCHAR" RESET "\n"; // char convert("!"); convert("\""); @@ -100,6 +102,9 @@ int main(int ac, char **av) { convert("|"); convert("}"); convert("~"); + + std::cout << "\n\n" B_GREEN "----------------------------------------------------\n" + << "\nINT" RESET "\n"; // int convert("0"); convert("-42"); @@ -147,6 +152,9 @@ int main(int ac, char **av) { convert(MAX_FLOAT_INT_PREC_4); convert(MAX_FLOAT_INT_PREC_5); convert(MAX_FLOAT_INT_PREC_6); + + std::cout << "\n\n" B_GREEN "----------------------------------------------------\n" + << "\nFLOAT" RESET "\n"; // float convert("0.0f"); convert("-4.2f"); @@ -181,6 +189,9 @@ int main(int ac, char **av) { convert(MAX_F_5".0f"); convert(MAX_F_6".0f"); convert(MAX_F_N".0f"); + + std::cout << "\n\n" B_GREEN "----------------------------------------------------\n" + << "\nDOUBLE" RESET "\n"; //double convert("0.0"); convert("-4.2"); diff --git a/d06/ex00/srcs/checkChar.cpp b/d06/ex00/srcs/checkChar.cpp index eba45de..0f5948c 100644 --- a/d06/ex00/srcs/checkChar.cpp +++ b/d06/ex00/srcs/checkChar.cpp @@ -22,10 +22,10 @@ bool isChar(std::string str) { bool checkChar(std::string str) { char c; - if (str.length() != 1 || isdigit(str[0])) + if (!isChar(str)) return false; - c = str[0]; + c = str[0]; std::cout << B_CYAN << c << B_YELLOW " char" RESET "\n"; fromChar(c); diff --git a/d06/ex00/srcs/convert.cpp b/d06/ex00/srcs/convert.cpp index ba1c1d7..16abcb4 100644 --- a/d06/ex00/srcs/convert.cpp +++ b/d06/ex00/srcs/convert.cpp @@ -2,6 +2,12 @@ #include #include "convert.h" +// f[] : is an array +// *f[] : is an array of pointers +// (*f[])() : is an array of pointers to functions with no parameters +// (*f[])(str) : is an array of pointers to functions with parameter str +// see : +// https://stackoverflow.com/questions/31643245/declaring-an-array-of-functions-of-type-void-c bool (*checkFunc[])(std::string str) = { checkChar,