Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <fstream>
- // https://esolangs.org/wiki/Poop
- int main(int argc, const char* argv)
- {
- const char* filename = "test.poop";
- std::ifstream file(filename);
- std::string word;
- char* paper = "0123456789abcdefghijklmnopqrstuvwxyz.,-!?+*<>#@$ۤ%&/()[]";
- char* wipes = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.,-!?+*<>#@$ۤ%&/()[]";
- short sheet = 0;
- #define PAPERLEN 57
- std::string smell = "";
- if(file.is_open())
- {
- while(file >> word)
- {
- if(word == "eat")
- {
- ++sheet;
- if(sheet > PAPERLEN)
- sheet -= PAPERLEN;
- }
- else if(word == "puke")
- {
- --sheet;
- if(sheet < 0)
- sheet += PAPERLEN;
- }
- else if(word == "poop")
- {
- char outchar = *(paper + sheet*sizeof(char));
- smell += outchar;
- }
- else if(word == "POOP")
- {
- char outchar = *(wipes + sheet*sizeof(char));
- smell += outchar;
- }
- else if(word == "sniff")
- {
- std::cout << smell << std::endl;
- }
- else if(word == "flush")
- {
- smell = "";
- sheet = 0;
- }
- else if(word == "fart") // Added my own keyword for inserting a space character
- {
- char outchar = ' ';
- smell += outchar;
- }
- else
- {
- std::cout << "[ERROR] Word \"" << word << "\" has no function." << std::endl;
- }
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement