// This is my code in main:
string word, processed_word, scrambled_word;
string first_letter, last_letter, final_word;
if (iss >> word)
first_letter = word;
last_letter = word[word.length() -1];
processed_word = process_word(word); // function for word to go to
scrambled_word = shuffle_word(processed_word); // function for word to go to
final_word = first_letter + scrambled_word + last_letter; // Puts parts of a word back together
cout << final_word;
out_file << word;
I have a program that is supposed to read lines from a file and send each word through a series of functions I made. The functions scramble the "inner" letters of a word.
I have a text file to import that says "Random Words" but when I run the code it only prints Random an infinite number of times, Random once, nothing at all, or Words once.
I'm not sure what I'm doing wrong, aren't streams supposed to read strings one word at a time? Shouldn't it be taking "Random" pass it through the functions, then take "Words" and do it again until there are no more words?
This code is printing the word "Random" with scrambled letters like it's supposed to, but it doesn't keep going onto "Words". If I change it from "if" to "while" is prints Random forever.
What am I doing wrong? How do you get it to go through each word once and then stop?