Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<fstream>
- using namespace std;
- fstream CreatAsciiArt (string filename){
- // file that program will create
- fstream newfile;
- // object for fstream class
- fstream file;
- // opening file
- file.open(filename.c_str(), ios::in);
- // checking if file has opened
- while (file.bad()) {
- cout << "There was an error opening the file " << endl;
- cout << "File name:";
- cin >> filename;
- file.open(filename.c_str(), ios::in);
- }
- int spacecount = 0;
- int charcount = 0;
- int linecount = 1;
- int linelength;
- string line;
- while (file.good()) {
- //gets new line
- getline(file, line);
- //get length of the new line
- linelength = line.length();
- for(int i = 0; i < linelength; i++) {
- //ignores first character which is line number
- if (i == 0) {
- }
- // ignores second character
- if (i == 1) {
- }
- // excludes all spaces and commas
- if ((line.at(i) != ' ') && (line.at(i) != '-') && (line.at(i) != ',') && (i != 0)) {
- // checks number of spaces for "sp" that are 2 digits
- if (line.at(i) == 's' && line.at(i + 1) == 'p') {
- if (isdigit(line.at(i - 3))) {
- cout << line.at(i - 3) << line.at(i - 2) << endl;
- }
- // checks number of spaces for "sp" that are 1 digits
- else {
- cout << (line.at(i - 2)) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement