RE: C question (linux)
- Posted by "Elliott S. de Andrade" <quantum_analyst at hotmail.com> Dec 11, 2003
- 553 views
fopen returns a FILE *. The return type should be FILE *, and any time you used int for a file descriptor, you have to replace it with FILE *. >From: Paul <draegur at comcast.net> >Subject: C question (linux) > >Does anyone have any suggestions as to why this: > >int file_open(char *name, int mode) >{ > >// return open(name, mode); > > return fopen(name, "r"); >} > >Would return the following when compiled: > >warning: return makes integer from pointer without a cast > > >This is driving me absolutely mad! I'm attempting to adjust the source of a >program I didn't write. For whatever reason, the old open() call is >returning >an invalid file descriptor (134758848 to be exact) so I am trying to change >it from open() to fopen(). The files passed through this routine are all >read >only types, so there is no reason for mode to ever be anything but 0 ("r") >so >I figured just change the ,mode) to a "r" > >If anyone could think of any reason why I would get that message. I have no >idea why, but I keep coming up with it. > >Thanks! >