Hiya.
My function 'wordstorage' used to have just
Code:
printf("%s", wordbank)
. That would work fine, as textblock would be updated with a new word, sent to 'wordstorage' and printed out.
Now the code looks like :
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(int argc, char *argv[]){
//-----------------------------------------------------------------------
char mytext[21] = {"summer and winter"};
char textblock[21] = {0};
char wordbank[10][21] = {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}};
int frequency[10] = {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}};
int largeindex = 0;
int smallindex = 0;
wordbank[smallindex];
frequency[smallindex];
int wordstorage(char textblock[], int smallindex, int largeindex, char wordbank[][21]);
//-----------------------------------------------------------------------
printf("%s\n", mytext);
int i = 0;
int j = 0;
while((i<22) && (j<22) && (mytext[i] != '\0')){
if(( mytext[i]>='a' && mytext[i]<='z' ) || ( mytext[i]>='A' && mytext[i]<='Z' )){
textblock[j] = mytext[i];
}
i++;
j++;
if (mytext[i] == ' ' || mytext == 0 || mytext[i] == '\0'){
textblock[j] = '\0';
wordstorage(textblock);
i++;
j = 0;
while (j<21){
textblock[j] = '0';
j++;
}
j=0;
}
}
return 0;
}
//-----------------------------------------------------------------------
int wordstorage(char textblock[], int smallindex, int largeindex, char wordbank[][21], int frequency[]){
if (largeindex == 0){
strcpy(wordbank[smallindex], textblock);
largeindex++;
}
while (smallindex < largeindex){
if (strcmp(wordbank[smallindex],textblock) != 0){
smallindex++;
if(smallindex == largeindex){
strcpy(wordbank[smallindex], textblock);
frequency[smallindex]++;
largeindex++;
}
}
if (strcmp(wordbank[smallindex],textblock) == 0){
frequency[smallindex]++;
}
}
return 0;
}
The errors are as follows :
(40) --- 'wordstorage' : function does not take 1 arguments
Also, should my small index be initialised inside my wordstorage function ? It needs to be reset every time a new word comes into the function right?
Any advice/help is as always, much appreciated.
Please and Thank You.
Edited Twice.