Thread: Error Problems

  1. #1
    Windu102
    Guest

    Error Problems

    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.
    Last edited by Windu102; 08-24-2008 at 03:37 AM.

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    You are declaring your function wordstorage inside of the function main(). Move it out of main() (to the top of your source before main() ) and try again.

    Todd
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by Dino View Post
    You are declaring your function wordstorage inside of the function main(). Move it out of main() (to the top of your source before main() ) and try again.

    Todd
    It has nothing to do with the incorrect number of parameters you pass to the function. Make sure that the parameters passed match the types specified in the prototype of the function
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed