#include <iostream>
#include <fstream>
#include <string>
using std::string;
using namespace std;

// if c is in str return true
bool in(std::string str, char c) {
    const char* s = str.c_str();
    while(*s) {
        if(c==*s) return true;
        ++s;
    }
    return false;
}

int main() {
    std::ifstream ifs("ospd.txt");
    std::ofstream ofs("wordlist0728.txt");
    std::string word;
    std::string letts;
    std::cout << "\nEnter letters: ";
	std::cin >> letts;
	const char* letters = letts.c_str();
    std::cout << "\nEnter the key letter: ";
    char keyLet{65};
    std::cin >> keyLet;
    int i{0}, j{0};
	cout << "letts = " << letts << ", keyLet = " << keyLet << '\n';
    while(ifs>>word) {
        const char* c = "";
        c = word.c_str();
        word = word.c_str();
		while(*c && in(letts, *c)) {
            ++c;
        }
        if (!*c) {
			std::cout << "*c = " << *c << ", in(" << word << ", " << keyLet << ") = " << in(word, keyLet) << '\n';
			std::cin.ignore();
			std::cin.get();
		}
        if(!*c && in(word,keyLet)) {
            ofs << word << std::endl;
            std::cout << word << std::endl;
        }
    }
}
