forked from sudo-su-FDEL/Crumble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrumble.cpp
50 lines (40 loc) · 1.14 KB
/
Crumble.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
//Delete words function
void delWords(int del_L) {
string StoreWord;
string filename, newfile;
//User is prompted for file
cout << "Please enter or copy and paste the file" << endl;
cin >> filename;
// New file created
ifstream WordIFILE(filename);
//User prompted for new file name
cout << "Please enter the name for your new file" << endl;
cin >> newfile;
//file closed
ofstream OutFile(newfile);
//looks for words with specified letter count
while (getline(WordIFILE, StoreWord)) {
if (StoreWord.length() > del_L) {
OutFile << StoreWord << endl;
}
}
WordIFILE.close();
OutFile.close();
//store file
while (getline(WordIFILE, StoreWord)) {
OutFile << StoreWord << endl;
}
}
int main() {
int del_L = 0;
//prompt user to enter the amount of letters
cout << "Enter the length of the characters to be deleted: ";
cin >> del_L;
//function called
delWords(del_L);
return 0;
}