When I try and compile a simple c program, I get an error
warning: passing argument 1 of 'fgets' from incompatible pointer type
I am compiling with gcc. What am I doing wrong?
Code:
#include <string.h>
#include <stdio.h>
#define MAX_CHAR 132
#define MAX_SIZE 65536
FILE *file;
int main(void)
{
file = fopen("words", "r");
char ch;
char string[MAX_CHAR];
char temp[MAX_CHAR];
char words[MAX_SIZE][MAX_CHAR];
register int counter = 0, number = 0, a = 0;
srand(time(NULL));
while ( fgets(&string, MAX_CHAR+1, file) != NULL )
{
a=0;
while ( string[a++] != '\n' );
string[a-1] = 0;
strcpy(words[counter++], string);
}
number = rand() % counter;
strcpy(string, words[number]);
while (strcmp(temp,string) != 0)
{
printf("Enter a character: " );
ch = getc(stdin);
a=0;
while ( string[a] != 0 )
{
if ( string[a] == ch )
temp[a] = ch;
else
{
if ( temp[a] == 0 || temp[a] == ' ' )
temp[a] = ' ';
}
a++;
}
printf("%s\n", temp);
}
return 0;
}