comparison between pointer and integer?

Moderators: Moderator, Global Moderator

Post Reply
Jim
Administrator
Administrator
Posts: 1324
Joined: Thu Jun 17, 2004 12:37 am

comparison between pointer and integer?

Post 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;
Love is all a matter of timing.

It's no good meeting the right person too soon or too late.

If I'd live in another time or place...

...my story might have had a very different ending.
Jim
Administrator
Administrator
Posts: 1324
Joined: Thu Jun 17, 2004 12:37 am

comparison between pointer and integer?

Post 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;
Love is all a matter of timing.

It's no good meeting the right person too soon or too late.

If I'd live in another time or place...

...my story might have had a very different ending.
Josh
Hero Member
Hero Member
Posts: 4627
Joined: Fri Jun 04, 2004 2:54 pm

comparison between pointer and integer?

Post 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
[align=center]

Image

“If you stop learning, you stop living.” ~Tami Quiring

“It's the rare man who understands the value of a single perfect rose.”

[/align]
Post Reply

Return to “C++”