Re: C question (linux)
- Posted by akusaya at gmx.net Dec 11, 2003
- 498 views
The fopen() function return a value with type FILE*, which is a pointer. In your function file_open(), the return type is int, it should be changed to FILE*, so that the function becomes: FILE* file_open(char *name, int mode) { return fopen(name, "r"); } P> Does anyone have any suggestions as to why this: P> int file_open(char *name, int mode) P> { P> // return open(name, mode); P> return fopen(name, "r"); P> } P> Would return the following when compiled: P> warning: return makes integer from pointer without a cast P> This is driving me absolutely mad! I'm attempting to adjust the source of a P> program I didn't write. For whatever reason, the old open() call is returning P> an invalid file descriptor (134758848 to be exact) so I am trying to change P> it from open() to fopen(). The files passed through this routine are all read P> only types, so there is no reason for mode to ever be anything but 0 ("r") so P> I figured just change the ,mode) to a "r" P> If anyone could think of any reason why I would get that message. I have no P> idea why, but I keep coming up with it.