comparison between pointer and integer?
Posted: Mon Aug 18, 2008 7:49 pm
Long story short, I'm trying to fix a program written a while ago that is no longer supported by the guy who wrote it. However, I'm getting a few (ok, a ton) of errors; most of them I can figure out but this one is confusing me. The error it's giving when I compile is:
[quote]asdf.c:4041: warning: comparison between pointer and integer
asdf.c:4042: warning: comparison between pointer and integer[/quote]
and here is the code surrounding it...
[code]int savefile(filename,buffer,mode,offset,size)
char *filename, *mode;
void *buffer;
long offset;
unsigned int size;
{
int error = 0;
if ((fp = fopen(filename, mode)) == NULL) goto trouble;
if (offset != 0)
if (fseek(fp, offset, 0) != 0){ fclose(fp);goto trouble;}
if (fwrite(buffer, size, 1, fp) == NULL) {fclose(fp);goto trouble;}
if (fclose(fp) < NULL) goto trouble;
return 1;
trouble:
sprintf(answer,"ERROR saving %s [error=%d]",filename,error);
msg("\n", answer, "",0);
return 0;
}[/code]
lines 4041 and 4042 are these two:
[code] if (fclose(fp) < NULL) goto trouble;
return 1;[/code]
[quote]asdf.c:4041: warning: comparison between pointer and integer
asdf.c:4042: warning: comparison between pointer and integer[/quote]
and here is the code surrounding it...
[code]int savefile(filename,buffer,mode,offset,size)
char *filename, *mode;
void *buffer;
long offset;
unsigned int size;
{
int error = 0;
if ((fp = fopen(filename, mode)) == NULL) goto trouble;
if (offset != 0)
if (fseek(fp, offset, 0) != 0){ fclose(fp);goto trouble;}
if (fwrite(buffer, size, 1, fp) == NULL) {fclose(fp);goto trouble;}
if (fclose(fp) < NULL) goto trouble;
return 1;
trouble:
sprintf(answer,"ERROR saving %s [error=%d]",filename,error);
msg("\n", answer, "",0);
return 0;
}[/code]
lines 4041 and 4042 are these two:
[code] if (fclose(fp) < NULL) goto trouble;
return 1;[/code]