1
0

Get Type Sizes.

This commit is contained in:
Captain ALM 2022-08-14 21:18:03 +01:00
parent 3a4c93189d
commit c87d8b9bd1
Signed by: alfred
GPG Key ID: 4E4ADD02609997B1
3 changed files with 13 additions and 30 deletions

View File

@ -1,9 +1,19 @@
#include <iostream>
#include "utils.hpp"
int main()
{
std::cout << "Add and Subtract 2 Numbers:\n\n";
utils::addSubTwoNumbers();
std::cout << "bool:\t\t" << sizeof(bool) << " bytes\n";
std::cout << "char:\t\t" << sizeof(char) << " bytes\n";
std::cout << "wchar_t:\t" << sizeof(wchar_t) << " bytes\n";
std::cout << "char16_t:\t" << sizeof(char16_t) << " bytes\n";
std::cout << "char32_t:\t" << sizeof(char32_t) << " bytes\n";
std::cout << "short:\t\t" << sizeof(short) << " bytes\n";
std::cout << "int:\t\t" << sizeof(int) << " bytes\n";
std::cout << "long:\t\t" << sizeof(long) << " bytes\n";
std::cout << "long long:\t" << sizeof(long long) << " bytes\n";
std::cout << "float:\t\t" << sizeof(float) << " bytes\n";
std::cout << "double:\t\t" << sizeof(double) << " bytes\n";
std::cout << "long double:\t" << sizeof(long double) << " bytes\n";
std::cout << "std::size_t:\t" << sizeof(std::size_t) << " bytes\n";
return 0;
}

View File

@ -1,19 +0,0 @@
#include <iostream>
namespace utils
{
int promptNumber(const char* prompt)
{
int toReturn {};
std::cout << prompt;
std::cin >> toReturn;
return toReturn;
}
void addSubTwoNumbers()
{
int num1 {promptNumber("Enter a integer: ")};
int num2 {promptNumber("Enter another integer: ")};
std::cout << num1 << " + " << num2 << " = " << num1 + num2 << "\n";
std::cout << num1 << " - " << num2 << " = " << num1 - num2 << "\n";
}
}

View File

@ -1,8 +0,0 @@
#ifndef utils_H_
#define utils_H_
namespace utils
{
int promptNumber(const char*);
void addSubTwoNumbers();
}
#endif // utils_H_