aboutsummaryrefslogtreecommitdiff
path: root/CST 126/Homework 1/main.cpp
diff options
context:
space:
mode:
authorArthur Spears <[email protected]>2024-04-17 19:27:26 -0700
committerArthur Spears <[email protected]>2024-04-17 19:27:26 -0700
commit7986ee1b60dcd6bf645dfb84272b887faa0aafb8 (patch)
treeb015260b6804acb0966c9ceb393d0fa9edd5938b /CST 126/Homework 1/main.cpp
parentAdded Unit Tests Project (diff)
downloadhomework-1-arthurtspears-7986ee1b60dcd6bf645dfb84272b887faa0aafb8.tar.xz
homework-1-arthurtspears-7986ee1b60dcd6bf645dfb84272b887faa0aafb8.zip
Added second unit tests project as example.
Diffstat (limited to 'CST 126/Homework 1/main.cpp')
-rw-r--r--CST 126/Homework 1/main.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/CST 126/Homework 1/main.cpp b/CST 126/Homework 1/main.cpp
index b4c91fc..f61633a 100644
--- a/CST 126/Homework 1/main.cpp
+++ b/CST 126/Homework 1/main.cpp
@@ -58,13 +58,31 @@ union FloatIntUnion
};
int main() {
- FloatIntUnion floatIntUnion {};
+
+ /*FloatIntUnion floatIntUnion {};
floatIntUnion.intFloat = 1.2345f;
std::cout << "Float: " << floatIntUnion.intFloat << std::endl;
std::cout << "Binary representation: " << std::bitset<32>(static_cast<uint32_t>(floatIntUnion.intFloat)) << std::endl;
std::cout << "As Int: " << floatIntUnion.uInt << std::endl;
- std::cout << "Binary representation: " << std::bitset<32>(floatIntUnion.uInt) << std::endl;
+ std::cout << "Binary representation: " << std::bitset<32>(floatIntUnion.uInt) << std::endl;*/
+ int input;
+ cout << "How big you want your array? ";
+ cin >> input;
+
+
+ int* intArray = nullptr;
+
+ try {
+ intArray = new int[input] {};
+ }
+ catch (const std::bad_alloc& ex) {
+ delete[] intArray;
+ intArray = nullptr;
+ std::cerr << "Exception allocating memor for int array:" << ex.what();
+ }
+
+ delete[] intArray;
return 0;
}