Fix Brainfuck input
This commit is contained in:
parent
c8a5b436ab
commit
482544ef8c
1 changed files with 14 additions and 4 deletions
|
@ -1,18 +1,28 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
std::string ops;
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
std::cerr << "No input given";
|
std::string line;
|
||||||
return 1;
|
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 };
|
std::vector<char> tape = { 0 };
|
||||||
int oix = 0;
|
int oix = 0;
|
||||||
int tix = 0;
|
int tix = 0;
|
||||||
int len = strlen(ops);
|
|
||||||
while (oix < len) {
|
while (oix < len) {
|
||||||
switch (ops[oix]) {
|
switch (ops[oix]) {
|
||||||
case '>':
|
case '>':
|
||||||
|
|
Loading…
Reference in a new issue