I'm writing a program and I keep getting a segmentation fault/error on a line that has a strcmp.
Code:
void wordCount(char *words[100], int now)
{
int WC[100];
int w;
int x;
int j;
int i;
for(i=0; i <= now; i++)
{
for(j= i+1; j <= now; j++)
{
strcmp(words[i], words[j]);
if(WC[i]== 0)
{
WC[i] = 1;
if(words[j] == words[i])
{
WC[i]++;
WC[j] = -1;
printf("%d:\t%s\n",WC[i],words[i]);
}
}
else if(WC[i] == -1)
{
WC[i]++;
printf("%d:\t%s\n",WC[i], words[i]);
}
}
}
}
If anyone could help me figure out the problem and how to fix it. And I use the function in another .c file that I compile at the same time.
Thanks.