d06 ex00 all checks are ok
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cctype> // isdigit()
|
||||
#include "color.h"
|
||||
#include "convert.h"
|
||||
|
||||
//Char toChar(str) {
|
||||
//
|
||||
//}
|
||||
void fromChar(char c) {
|
||||
int i;
|
||||
float f;
|
||||
double d;
|
||||
|
||||
i = static_cast<int>(c);
|
||||
std::cout << std::setw(7) << std::left << "int" << B_CYAN << i << RESET "\n";
|
||||
f = static_cast<float>(c);
|
||||
std::cout << std::setw(7) << std::left << "float" << B_CYAN << f << RESET "\n";
|
||||
d = static_cast<double>(c);
|
||||
std::cout << std::setw(7) << std::left << "double" << B_CYAN << d << RESET "\n";
|
||||
}
|
||||
|
||||
char toChar(std::string str) {
|
||||
return str[0];
|
||||
}
|
||||
|
||||
bool isChar(std::string str) {
|
||||
if (str.length() != 1 || isdigit(str[0]))
|
||||
@@ -14,17 +24,17 @@ bool isChar(std::string str) {
|
||||
}
|
||||
|
||||
bool checkChar(std::string str) {
|
||||
|
||||
// char c;
|
||||
|
||||
char c;
|
||||
std::cout << "char\n";
|
||||
|
||||
if (str.length() != 1 || isdigit(str[0]))
|
||||
return false;
|
||||
|
||||
// c = toChar(str);
|
||||
// std::cout << "char"RESET" equal to : "B_CYAN << c << RESET << "\n";
|
||||
// fromChar(c);
|
||||
c = toChar(str);
|
||||
std::cout << B_YELLOW << str << RESET " is a char"
|
||||
<< " of value "
|
||||
<< B_CYAN << c << RESET << "\n";
|
||||
fromChar(c);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user