Get Type Sizes.
This commit is contained in:
parent
3a4c93189d
commit
c87d8b9bd1
16
main.cpp
16
main.cpp
@ -1,9 +1,19 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "utils.hpp"
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::cout << "Add and Subtract 2 Numbers:\n\n";
|
std::cout << "bool:\t\t" << sizeof(bool) << " bytes\n";
|
||||||
utils::addSubTwoNumbers();
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
19
utils.cpp
19
utils.cpp
@ -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";
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user