Hello ElleJay,
Been working with your program a bit and I find this:
so I'm reading the text into a character array |
partially correct. You do read into "ch" which is an array, but also into "q" ans "s" which are linked lists. It all works, but I do not think that is what you wanted.
What I think I might do is to use the "ch" array to store a word then call a function that would reverse the letters into a temp array then compare the two arrays maybe returning a bool from the function.
Your next problem is having to deal with multiple words in one line along with ","s in some of the lines. Doable just needs some extra checking.
I think you have over thought this and are making it harder than it needs to be.
You may want to start with reading the file and extracting the words to work with. Yo might consider a 2D array to store each word
char arr[20][20]{};
. This will give you twenty lines, e.g., 20 words and the second dimension would be the character array for each word. The 20s are just an idea they can be any number that you would need.
This is not perfect, but an idea of what you can do that seemed to work a little better:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
in >> c;
while (c != '$' && c != '\n') // <--- Added second part.
{
c = toLower(c);
std::cout << c << ' ';
enqueue(q, c);
push(s, c);
ch[i] = c;
i = i + 1;
in.get(c); // <--- Changed to work with while condition,
num = num + 1;
}
|
Hope that helps,
Andy