push ex01
This commit is contained in:
+6
-17
@@ -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
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user