Logic help with strings and arrays.
Hi everyone.
Im trying to write a code using scanf to take in any chunk of text, and i want to perform a word frequency count. Now from what i understand i should copy my string into an array, the problem is, what if i write a sentence, or then i write a paragraph... hows my array meant to adjust? So if i set myself a limit, like i know the MAXIMUM ill have is 50 unique words, the approach i think of goes like this.
Having two separate arrays, wherein one stores the word if its new, but to do that i need the second array which copies the word in at the same time as the first array, and if the word is a repeat it increments the frequency of the word but doesn't let it get copied into the first array.
The thing is im thinking then my second array is not only storing the word, but the frequency as well, which is exactly what i want, but how can i display both the characters and integers in one array ?!
Furthermore, i don't see how i can copy the string across word at a time unless its already IN an array.
I'm so confused, can someone please help me untangle this mess. I'm not talking about CODE, but rather please help me understand the logic behind it.Thank you.
P.S I've looked into 2D arrays,but how will that help?