Hi to all,
I have this program:
Code:
/*** HERE the various #define ***/
#define BUFLEN 100
struct node
{
char info[BUFLEN] ;
struct node *pun ;
} ;
typedef struct node* mylist ;
/*** HERE the various Prototype ***/
int main(int argc, char *argv[])
{
int occur, n;
mylist testa = NULL ;
char myWord[20];
char mystring[BUFLEN];
/**** HERE the Input code forf mystring and the code inserting each
mystring in the struct****/
/* I search the occurrence number of myword in the entire list of mystrings*/
occur = word_counter(testa, myword, n) ;
printf("The occurrences are: %d\n",occur);
}
int word_counter(mylist p, const char *buf, int n)
{
int j,occ;
char temp[BUFLEN];
occ = 0;
n = 0;
j = 0;
while (p != NULL)
{
strcpy(temp, p->info);
occ = eachline_counter(temp, buf, j);
n = n + occ;
printf("Occurrences for this string are: %d\n", n ) ;
p = p->pun ;
}
return (n) ;
}
int eachline_counter(char *a, char *b, int rip)
{
int cnt = 0;
char *sptr = a;
while ( *sptr != '\0' && ( sptr = strstr( sptr, b ) ) != NULL )
{
cnt++;
sptr += strlen( b );
}
printf( "%d\n", cnt );
return (cnt);
};
But when I compile the program, the GCC compiler return to me this
error:
>> In function 'word_counter'
>> Passing arg 2 of eachline_counter discards qualifier from pointer target type
Sure, I mistake something; but I don't see. Please can You help me ?