Im new in programming c with arrays and files. Im just trying to run the following code but i get warnings like that:
23 44 warning: assignment makes pointer from integer without a cast
53 error: expected expression before ‘char’
Any help? It might be silly... but I cant find what's wrong.
#include <stdio.h>
FILE *fp;
FILE *cw;
char filename_game[40],filename_words[40];
int main()
{
while(1)
{
/* Input filenames. */
printf("\n Enter the name of the file \n");
gets(filename_game);
printf("\n Give the name of the file2 \n");
gets(filename_words);
/* Try to open the file with the game */
fp=fopen(/* args omitted */); //line23**
if (fp!= NULL)
{
printf("\n Successful opening %s \n",filename_game);
fclose(fp);
puts("\n Enter x to exit,any other to continue! \n ");
if ( (getc(stdin))=='x')
break;
else
continue;
}
else
{
fprintf(stderr,"ERROR!%s \n",filename_game);
puts("\n Enter x to exit,any other to continue! \n");
if (getc(stdin)=='x')
break;
else
continue;
}
/* Try to open the file with the names. */ //line 44**
cw=fopen(/* args omitted */);
if ( cw!=NULL )
{
printf("\n Successful opening %s \n",filename_words);
fclose(cw);
puts("\n Enter x to exit,any other to continue \n ");
if ( (getc(stdin))=='x')
break; //line 53**
else
continue;
}
else
{
fprintf(stderr,"ERROR!%s \n",filename_words);
puts("\n Enter x to exit,any other to continue! \n");
if (getc(stdin)=='x')
break;
else
continue;
}
}
return 0;
}