1). Open a .txt file containing words in a list.
2). Add to the end of each word the number 1, repeat the process but this time add 12 to end, and 123, and so on...
3). Display the words with the 1/12/123 added to them in the console
4). Write that output to a new file.
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
usingnamespace std;
void centertext(char* s);
int UserChoice();
int main()
{
int a;
a = UserChoice();
if(a==5){
centertext("Thankyou for using Wordlist Generator 1.1!");
cout << endl;
cout << "Press ENTER to continue..." << endl;
cin.ignore();cin.get();
exit(1);
}
string nDirectory;
string buffer;
cout << "Please enter path to the file: " << endl;
string fDirectory;
cin >> fDirectory;
fstream myfile(fDirectory.c_str());
while (!myfile.eof())
{
myfile >> buffer;
buffer[0] = toupper(buffer[0]);
if(a==1) {
cout << buffer << "1" << endl;
}
elseif(a==2){
cout << buffer << "12" << endl;
}
elseif(a==3){
cout << buffer << "123" << endl;
}
elseif(a==4){
cout << buffer << "1" << endl;
cout << buffer << "12" << endl;
cout << buffer << "123" << endl;
}
}
cout << "Press ENTER to continue..." << endl;
cin.ignore();cin.get();
return 0;
}
int UserChoice() {
int x;
cout << "Welcome to the Word List Generator Version 1.0" << endl;
cout << "Please choose from the following options: " << endl;
cout << "1. Append 1 to the end of each and every word and Capitalize first char" << endl;
cout << "2. Append 12 to the end of each and every word and Capitalize first char" << endl;
cout << "3. Append 123 to the end of each and every word and Capitalize first char." << endl;
cout << "4. Append 1, then 12, then 123 to each and every word and Capitalise first char." << endl;
cout << "5. Exit" << endl;
cin >> x;
cout << endl;
cout << "You chose option: " << x << endl;
cout << endl;
return x;
}
void centertext(char* s){
int l = strlen(s);
int pos = (int)((80-l)/2);
for(int i=0; i<pos; i++)
cout << " ";
cout << s << endl;
}