c - Unknown reason for gcc warning: assignment makes pointer from integer without cast -


this supposed compiled static library homework. when use command: "gcc -c innoprompt.c inprompt.c" recieve warning , points line "fin = openfileprompt();" innoprompt.c. cannot see how cause warning. also, when compile actual program library linked, same warning. due nature of assignment, not allowed change file calling functions library.

this header files.

#pragma once  #ifndef libinfileutil_h #define libinfileutil_h  #include <stdio.h>  file* openinputfile(char* filename); file* openinputfile();  #endif 

this inprompt.c #include "libinfileutil.h"

file* openfileprompt(){     char filename[100];     file* fin = null;     do{         printf("\nplease enter file opened: ");         fscanf(stdin,"%s",filename);         while(fgetc(stdin) !='\n');         fin = fopen(filename, "r");         if(fin==null)             printf("failed open file. please try file name.\n");     }while(fin==null);     return fin; } 

and lastly, innoprompt.c

#include "libinfileutil.h"  file* openinputfile(char* filename){     file* fin = null;     fin = fopen(filename, "r");         if(fin==null)             fin = openfileprompt();     return fin; } 

the header doesn't declare function openfileprompt(), how compiler know returns pointer instead of int?

as stands, header declares same function twice, once prototype, once without. maybe should replace second with:

file *openfileprompt(void); 

i'd use void in function definition symmetry. note in c (as opposed c++), there big difference between declaration and:

file *openfileprompt(); 

this says 'the function openfileprompt() exists, returns file *, takes arbitrary (but fixed) number of arguments of unspecified type'.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -