// Assignment 1 (C++).cpp : This file contains the 'main' function. Program execution begins and ends there. // #include #include #include int main() { 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 MemoryChars(1024); // Pre-reserve } } struct MemoryStream { private: long position = 0; long length = 0; std::vector 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); } } }; // 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