By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,740 Members | 844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,740 IT Pros & Developers. It's quick & easy.

error C2664: 'parseInput' : cannot convert parameter 2 WHY?

P: 64
I have no idea why am I getting an error C2664: 'parseInput' : cannot convert parameter 2 from 'main::WORD_STRUCT [200]' to 'struct WORD_STRUCT []'

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define FILENAME 80
  6. #define MAX_SIZE 1000
  7. #define CHAR_SIZE 200
  8. #define FLUSH while(getchar() != '\n')
  9.  
  10.  
  11. // Prototype Declarations
  12. int getFileName (char nameStr[]);
  13. int parseInput( char tempStr[], struct WORD_STRUCT structAry[]);
  14.  
  15. int main (void)
  16. {
  17. //    Local Definitions
  18.     FILE *inFile;
  19.     int numElems;
  20.     int nameSize;    
  21.     int i;
  22.     char nameStr [FILENAME];
  23.     char originalStr[MAX_SIZE];
  24.     char tempStr[MAX_SIZE];
  25.     char *pArray [CHAR_SIZE];
  26.  
  27.     typedef struct {
  28.     char *word;
  29.     int count;
  30.     } WORD_STRUCT;
  31.  
  32.  
  33.     typedef struct nodeStruct {
  34.     WORD_STRUCT data;    /* can be any type */
  35.     struct nodeStruct *next; /* points to the next 
  36.                                 node */
  37.     } NODE;
  38.  
  39.     WORD_STRUCT structAry[CHAR_SIZE];
  40.  
  41. //    Statements
  42.     printf("Beginning of Program.\n");
  43.  
  44.     if (!(inFile = fopen (nameStr, "r")))
  45.         {
  46.          printf("Error opening %s for reading\n", nameStr);// Prints Error if cannot find file
  47.          exit (100); // Quit if cannot find file
  48.         } // if open input 
  49.  
  50.      while(fgets ( tempStr , MAX_SIZE , inFile)!=NULL);
  51.     {
  52.     parseInput(tempStr, structAry); // This is where I am getting the ERROR
  53.     }
  54.  return 0;
  55. }
  56.  
  57.  
Any help would be great
Jun 25 '07 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
Your typedef for WORD_STRUCT comes after the function prototype of your parseInput() function and WORD_STRUCT is a type so you need to remove the struct qualifier from the function argument. Here's what I did. Compiles fine.
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define FILENAME 80
  6. #define MAX_SIZE 1000
  7. #define CHAR_SIZE 200
  8. #define FLUSH while(getchar() != '\n')
  9.  typedef struct {
  10.     char *word;
  11.     int count;
  12.     } WORD_STRUCT;
  13.  
  14. // Prototype Declarations
  15. int getFileName (char nameStr[]);
  16. int parseInput( char tempStr[], WORD_STRUCT structAry[]);
  17.  
  18. int main (void)
  19. {
  20. //  Local Definitions
  21.     FILE *inFile;
  22.     int numElems;
  23. etc....
  24.  
Jun 26 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.