-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject1.cpp
More file actions
118 lines (91 loc) · 3.76 KB
/
Project1.cpp
File metadata and controls
118 lines (91 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <iomanip>
#include <iostream>
#include <chrono>
#include <ctime>
#include <format>
#include <print>
#include <boost/predef.h>
#include <algorithm>
#include <iterator>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS
using namespace std;
//Using voids requires them to be placed OUTSIDE of the int main. Otherwise you'll have a failure to compile. Also they should never have values!
//int main just functions as a function to execute all the defined statements inside of it. Execution order is vital for other statements. Most shouldn't be worried about execution order.
//Unlike SwiftUI
int main() //Note to self always, always, have variables defined INSIDE of int main or other int's.
{
//Time Functionality begins here
auto start = chrono::system_clock::now(); //Basically tells the CMD line to time the runtime. Acts like a stopwatch. In PROD env's doesn't really matter.
int funnynum;
funnynum = 5;
int anothernum{ 45 };
int inputx{};
int inputy{};
if (BOOST_OS_WINDOWS)
cout << "This is a Windows Machine" << endl;
if (BOOST_OS_LINUX)
cout << "This is a Linux machine" << endl;
if (BOOST_OS_MACOS)
cout << "This is a macOS machine" << endl;
if (BOOST_OS_IRIX)
cout << "It's a Unix System I know this!" << endl;
//Begin writing clock function
time_t now = time(0);
char* dt = ctime(&now);
cout << "The local date and time is " << dt << endl;
tm* gmtm = gmtime(&now);
dt = asctime(gmtm);
cout << "The UTC date and time are currently" << dt << endl;
//Note does order of how things are outputted and stored matter?
//Note to self. No, no it does not matter.
cout << "This process is timed" << endl;
cout << "Hello World!\n";
cout << "This combines a string and a variable. So anothernumber is equal to: " << anothernum << endl;
cout << "The funny number of the day is: " << funnynum << endl;
cout << "Please enter a number on the next line and also on the on after." << endl;
cin >> inputx >> inputy;
cout << "You've entered: " << inputx << " and also : " << inputy << endl;
//Begin std::sort notes
int array[]{ 30,40,50,60,70 };
std::sort(std::begin(array), std::end(array));
for (int i{ 0 }; i < static_cast<int>(std::size(array)); ++i)
std::cout << array[i] << ' ';
std::cout << '\n';
return 0;
//Begin Listing operator and their size
cout << "All this does is list out what bytes are in a operator." << endl;
cout << "Since all machines are different. All your bytes will vary." << endl;
cout << left;
cout << setw(16) << "bool" << sizeof(bool) << "bytes\n";
cout << setw(16) << "char" << sizeof(char) << "bytes\n";
cout << setw(16) << "short" << sizeof(short) << "bytes\n";
cout << setw(16) << "int" << sizeof(int) << "bytes\n";
cout << setw(16) << "long" << sizeof(long) << "bytes\n";
cout << setw(16) << "long long" << sizeof(long long) << "bytes\n";
cout << setw(16) << "float" << sizeof(float) << "bytes\n";
cout << setw(16) << "double" << sizeof(double) << "bytes\n";
cout << setw(16) << "long double" << sizeof(long double) << "bytes\n";
//End listing operator and their byte size
auto end = chrono::system_clock::now(); // Tells the stopwatch to stop and outputs it at the end of execution.
//Below just tells the machine to display time with date and how long the code ran.
chrono::duration<double> elapsed_seconds = end - start;
time_t end_time = chrono::system_clock::to_time_t(end);
struct tm timeinfo;
if (localtime_s(&timeinfo, &end_time) == 0)
{
char buffer[26];
if (asctime_s(buffer, sizeof(buffer), &timeinfo) == 0)
{
cout << "finished process at " << buffer
<< "elapsed time: " << elapsed_seconds.count() << "s"
<< endl;
}
}
// End Time functionality
ios_base::sync_with_stdio(false);
int x;
cin >> x;
cin.ignore(std::cin.rdbuf()->in_avail());
cout << "press enter\n";
cin.ignore();
}