Saturday, 24 September 2016

c - warning: incompatible pointer types passing 'char *' to parameter of type 'FILE *' (aka 'struct __sFILE *')


I am trying to execute my code but I seem to get this incompatible warning.



int Read_Data_File(void)

{
FILE *ptr_file;
char *end = "0.0.0.0 none";
char *buf;
int endLoop = 0;

ptr_file = fopen("CS222_Inet.txt", "r");


if (!ptr_file)

return 1;

int i = 0;

while (!feof(ptr_file)){
addr[i]=(struct address_t *)malloc(sizeof(struct address_t));
fscanf(ptr_file,"%s",buf);
if(!(strcmp(buf, end) == 0)){
fscanf(buf,"%d %d %d %d %s", &addr[i]->IP1, &addr[i]->IP2, &addr[i]->IP3, &addr[i]->IP4, addr[i]->name);
n++;

}
i++;
}

fclose(ptr_file);
return 0;
}


I want this program to read the file and also store my structure type into my buf pointer.




Warning Output:



project.c:65:11: warning: incompatible pointer types passing 'char *' to
parameter of type 'FILE *' (aka 'struct __sFILE *')
[-Wincompatible-pointer-types]
fscanf(buf,"%d %d %d %d %s", &addr[i]->IP1, &add...
^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/stdio.h:250:30: note:
passing argument to parameter here

int fscanf(FILE * __restrict, const char * __restrict, ...) __scanf...
^

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...