Page 1 of 1

comparison between pointer and integer?

Posted: Mon Aug 18, 2008 7:49 pm
by Jim
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: Select all

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;
	}
lines 4041 and 4042 are these two:

Code: Select all

	if (fclose(fp) < NULL) goto trouble;
	return 1;

comparison between pointer and integer?

Posted: Tue Aug 19, 2008 12:55 am
by Jim
Got the answer, thanks Hayden

Code: Select all

	if (fwrite(buffer, size, 1, fp) == 0) {fclose(fp);goto trouble;}
	if (fclose(fp) < 0) goto trouble;

comparison between pointer and integer?

Posted: Tue Aug 19, 2008 3:47 am
by Josh
lol couldn't believe I actually knew how to fix this.. Boo @ Hayden for ruining my moment to make it look like I know a lot /blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />

Usually if you fix one thing it will get rid of a ton of errors lol