style: adding the function in other file
This commit is contained in:
parent
5d93eb2fd3
commit
ebbd489d9b
2 changed files with 71 additions and 0 deletions
31
cpp06/ex00/sources/char.cpp
Normal file
31
cpp06/ex00/sources/char.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* char.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/22 22:06:48 by rparodi #+# #+# */
|
||||
/* Updated: 2025/03/22 22:10:24 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ScalarConverter.hpp"
|
||||
|
||||
bool isChar(std::string const &str) {
|
||||
if (str.length() == 1 && !std::isdigit(str[0])) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void convertChar(std::string const &str) {
|
||||
char toChar = str[0];
|
||||
int toInt = static_cast<int>(toChar);
|
||||
float toFloat = static_cast<float>(toChar);
|
||||
double toDouble = static_cast<double>(toChar);
|
||||
std::cout << "Char: '" << toChar << "'" << std::endl;
|
||||
std::cout << "Int: " << toInt << std::endl;
|
||||
std::cout << "Float: " << toFloat << ".0f" << std::endl;
|
||||
std::cout << "Double: " << toDouble << ".0" << std::endl;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue