Originally Posted by
zyxx_66
I've sent the source code ,Adak, for anyone else that wanted to help (which i really need) i could send you my source code so far, but cannot display it in the board, sorry, i have a reason.
O yeah what do you mean i must include it in the two word arrays i'll be using? and what is that compiler testing means? i must write a source code with that kind of argument?
As i said, i got stuck in getting the specific words that was from the file to be printed in my program along with it's occurence
By the way, i'm using Windows VIsta , so i don't have the Unix sorting function. I forgot to warn about it in the last part of my assignment, sorry.
You can't use structures, according to the assignment. You'll need parallel arrays. One for words, and one for the tally of words.
so add:
Code:
char words[1000][25] = { { '\0' } };
int tally[1000] = { 0 };
and for simplicity, we'll do this on the stack, so this goes before int main(), and after the #include lines of code.
Then in your code, where you get a letter, you'll need to add that letter into a separate buffer. (we could use a special row of the same array, but let's not).
Code:
i = 0;
while (!issspace(c) ) {
buff[i++] = c; //where c is a char. Is your c a char?
}
/* Then we need to see if this word is in the words array */
for(i = 0, inIt = 0; i < count; i++) { //assume it's not in the array
if((strcmp(buff, words[i]) == 0) { //test each word
inIt = 1; //it's in there, set the flag
tally[i]++; //increment tally for that word
}
}
if(inIt == 0) { //it needs to be added to words
strcpy(words[count], buff); //copy the string into words at count's row
tally[count]++; //increment tally[count]
count++; //increment count
}
I haven't run this code, so it may not be right, but it will be close. The string functions will need a header, of course, so add that, and see if this compiles and runs OK, so far, with the rest of your program.
If you get stuck, you know where we are.