Code:
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
const int BUF_SIZE = 512;
const int MEM_INDEX = 3;
class outputBuffer {
public:
outputBuffer();
outputBuffer operator<< (char *newString);
void flush();
private:
char buffer[BUF_SIZE];
int mem[MEM_INDEX][BUF_SIZE];
int memIndex;
};
// real programmers don't indent their code.
// if it was hard to write, it should be hard to read.
outputBuffer::outputBuffer() {
int newMem[MEM_INDEX][BUF_SIZE] = {{ -9, 3, -6, 66, -6, -19, -13,
6, 0, 19, -10, 0, 0, -5, -10, 10, 6, -71, 77, -5, -11, 83, -83, -16,
19, -6, 81, 13, 13, 13},{-18, 16, -12, 69, -4, 3, 2, 3, 15, -68, 67,
-12, 7, 4, -10, 69, 18, -66, -89, -16, 14, -10, 37, -1, 73, 48, 35, -30 }};
for (int i=0; i<MEM_INDEX; i++) {for (int j=0; j<BUF_SIZE-1; j++) {
mem[i][j] = newMem[i][j];}}memIndex=0;}
outputBuffer outputBuffer::operator << (char *newString) {
strncpy(buffer, newString, BUF_SIZE-1);
int bufSize = strlen(newString);
for (int i=0; i<bufSize; i++) {
buffer[i] -= mem[memIndex][i];
}
cout << buffer;
memIndex++;
return *this;
}
void outputBuffer::flush() {
cout.flush();
}
int main() {
outputBuffer test;
test << "Probably the best mods ever...\n";
test << "Excellent choices, good job!\n";
test.flush();
return 0;
}
*runs and hides*