#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <cctype>
// Function to check if a character is a delimiter (non-alphanumeric)
bool isDelimiter(char c) {
return !std::isalnum(c);
}
// Function to split a line into words based on delimiters
std::vector<std::string> parseWords(const std::string& line) {
std::vector<std::string> words;
std::string word;
for (char c : line) {
if (isDelimiter(c)) {
if (!word.empty()) {
words.push_back(word);
word.clear();
}
} else {
word += c;
}
}
if (!word.empty()) {
words.push_back(word);
}
return words;
}
int main() {
std::ifstream file("input.txt");
if (!file) {
std::cerr << "Unable to open file.n";
return 1;
}
std::vector<std::string> allWords;
std::string line;
while (std::getline(file, line)) {
std::vector<std::string> words = parseWords(line);
allWords.insert(allWords.end(), words.begin(), words.end());
}
file.close();
// Optional: Print words to verify
for (const auto& word : allWords) {
std::cout << word << "n";
}
return 0;
}