Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<string>
- using namespace std;
- int main()
- {
- //initiate variables
- int choice, num;
- string name, art;
- //print instructions to console
- cout << "Please choose:" << endl;
- cout << "(1)Create acii art" << endl;
- cout << "(2)Create instructions" << endl;
- cout << "<";
- //user input for choice
- cin >> choice;
- //distinguish between creating art or instr.
- switch (choice)
- {
- //Creating Art
- case 1:
- {
- //Retrieving input file
- cout << "File Name: ";
- cin >> name;
- ifstream infile(name.c_str());
- //Creating output file
- name = name.substr(0,name.length()-4);
- name = name.append("_art.txt");
- ofstream outfile(name.c_str());
- //Loop through file
- while(!infile.eof())
- {
- //Ignore characters that describe # of line
- infile >> art;
- infile >> art;
- //Loop through line
- infile >> num;
- infile >> art;
- //loop for writing art to file
- for (int i =0; i < num; i++)
- {
- //if "sp" print space
- if (art.substr(0, art.length()-1) == "sp")
- {
- outfile << " ";
- }
- //otherwise print the given char
- else
- {
- outfile << art;
- }
- }
- }
- break;
- }
- }
- //Creating Instr
- case 2:
- {
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement