Fix Brainfuck input

This commit is contained in:
1computer1 2019-06-03 19:00:06 -04:00
parent c8a5b436ab
commit 482544ef8c

View file

@ -1,18 +1,28 @@
#include <iostream>
#include <vector>
#include <string.h>
#include <string>
int main(int argc, char **argv) {
std::string ops;
if (argc == 1) {
std::cerr << "No input given";
return 1;
std::string line;
while (std::getline(std::cin, line)) {
ops.append(line);
}
if (ops.empty()) {
std::cerr << "No input given";
return 1;
}
} else {
ops.assign(argv[1], strlen(argv[1]));
}
char *ops = argv[1];
int len = ops.length();
std::vector<char> tape = { 0 };
int oix = 0;
int tix = 0;
int len = strlen(ops);
while (oix < len) {
switch (ops[oix]) {
case '>':