push ex01

This commit is contained in:
Leo Firmin
2026-02-02 00:50:54 +01:00
parent f085080c7d
commit e3ff4a9bc9
8 changed files with 151 additions and 23 deletions
+6 -17
View File
@@ -2,23 +2,12 @@
int main(int argc, char **argv)
{
std::cout << std::endl;
if (argc < 2)
std::cout << "Usage: ./convert <value_to_cast1> <value_to_cast2> ..." << std::endl;
int i = 1;
while (argv[i])
{
std::cout << "############## OUTPUT " << i << " ##############" << std::endl;
std::cout << "user input:\t\"" << argv[i] << "\"" << std::endl;
if (argv[i][0])
ScalarConverter::convert(argv[i++]);
else
std::cout << "Argument " << i++ << " is empty." << std::endl;
std::cout << std::endl;
}
if (argc != 2)
{
std::cerr << "Usage: ./convert <literal>" << std::endl;
return 1;
}
ScalarConverter::convert(argv[1]);
return (0);
}
+1 -1
View File
@@ -3,7 +3,7 @@ CXXFLAGS = -Wall -Wextra -Werror -std=c++98
OBJDIR = obj
SOURCES = Main.cpp ScalarConverter.cpp
OBJECTS = $(addprefix $(OBJDIR)/, $(SOURCES:.cpp=.o))
NAME = Bureaucrat
NAME = ScalarConverter
all: $(NAME)
+5 -5
View File
@@ -205,14 +205,14 @@ void ScalarConverter::toOther(const std::string &input)
void ScalarConverter::convert(const std::string &input)
{
if (isChar(input))
if (isInt(input))
toInt(input);
else if (isChar(input))
toChar(input);
else if (isInt(input))
toInt(input); ////////////////
else if (isFloat(input))
toFloat(input); //////////////
toFloat(input);
else if (isDouble(input))
toDouble(input); /////////////
toDouble(input);
else if (isOther(input))
toOther(input);
else