2021-03-26 10:35:41 +13:00
|
|
|
|
// Assignment 1 (C++).cpp : This file contains the 'main' function. Program execution begins and ends there.
|
2021-03-26 10:08:04 +13:00
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
2021-03-26 10:35:41 +13:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <vector>
|
2021-03-26 10:08:04 +13:00
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
2021-03-26 10:35:41 +13:00
|
|
|
|
std::cout << "┌────────────────────────────────────────────────┐\n";
|
|
|
|
|
std::cout << "│ 159.341 2021 Semester 1, Assignment 1 (C++) │\n";
|
|
|
|
|
std::cout << "│ Submitted by Brychan Dempsey, 14299890 │\n";
|
|
|
|
|
std::cout << "└────────────────────────────────────────────────┘\n";
|
|
|
|
|
|
|
|
|
|
bool exit = false;
|
|
|
|
|
while (!exit) {
|
|
|
|
|
std::vector<char> MemoryChars(1024); // Pre-reserve
|
|
|
|
|
|
|
|
|
|
}
|
2021-03-26 10:08:04 +13:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-26 10:35:41 +13:00
|
|
|
|
struct MemoryStream {
|
|
|
|
|
private:
|
|
|
|
|
long position = 0;
|
|
|
|
|
long length = 0;
|
|
|
|
|
std::vector<char> chars;
|
|
|
|
|
|
|
|
|
|
bool ensureCapacity(long step) {
|
|
|
|
|
// Size exceeds the bounds of the vector, resize
|
|
|
|
|
if (position + step >= chars.size()) {
|
|
|
|
|
chars.resize(position + step);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
MemoryStream(long Reserved) {
|
|
|
|
|
chars.assign(Reserved, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char ReadChar() {
|
|
|
|
|
if (++position >= length) return -1;
|
|
|
|
|
return chars[position];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char PeekChar() {
|
|
|
|
|
char result = ReadChar();
|
|
|
|
|
position--;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool writeChar(char c) {
|
|
|
|
|
ensureCapacity(1);
|
|
|
|
|
if (position == length) length++;
|
|
|
|
|
chars[++position] = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool writeChars(char* c, int count) {
|
|
|
|
|
ensureCapacity(count);
|
|
|
|
|
if (position >= length - count) length = position + count;
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
chars[i + position] = *(c + i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-26 10:08:04 +13:00
|
|
|
|
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
|
|
|
|
|
// Debug program: F5 or Debug > Start Debugging menu
|
|
|
|
|
|
|
|
|
|
// Tips for Getting Started:
|
|
|
|
|
// 1. Use the Solution Explorer window to add/manage files
|
|
|
|
|
// 2. Use the Team Explorer window to connect to source control
|
|
|
|
|
// 3. Use the Output window to see build output and other messages
|
|
|
|
|
// 4. Use the Error List window to view errors
|
|
|
|
|
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
|
|
|
|
|
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
|