bad file pointer from fopen

plug-discuss@lists.plug.phoenix.az.us plug-discuss@lists.plug.phoenix.az.us
Thu, 18 Apr 2002 16:14:16 -0400


You should restart this thread over on the plug-devel list.  That's where us programmers hangout too!

Alan

On Thu, 18 Apr 2002 11:38:19 -0700 lynn tilby <lynn@sol.createv.com> wrote:


I am receiving a bad file pointer from fopen.

The permissions on the foo_data (input) file are 777, 
owner is the person executing the compiled code, the code is
being executed in the same dir as the foo_data file.

The interesting thing is that fopen is NOT returning a NULL
file pointer.  The program continues on and gives the message
of successfully opening foo_data.  In the real (non-example)
code the prog eventually core dumps on the fread.

gcc version is:
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)

Here is the sample code:
#include <stdio.h>
FILE *in_ptr, *fopen();
main()
{
  if((in_ptr = fopen ( "./foo_data" , "r")) == NULL)
  {
    printf("\nfopen failed on foo_data\n\n");
    exit(1);
  }
  printf("\nfopen successful on foo_data\n\n");
}

Here is the xxgdb output:
Breakpoint 1, 0x804838c in fopen ()
(xxgdb) step
Single stepping until exit from function fopen,
which has no line number information.
_IO_new_fopen (filename=0x8048522 "./foo_data", mode=0x8048520 "r") at
iofopen.c:42
42    iofopen.c: No such file or directory.
(xxgdb)

ANY THOUGHTS??????

Thanks for you response!
Lynn
________________________________________________
See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't post to the list quickly and you use Netscape to write mail.

PLUG-discuss mailing list  -  PLUG-discuss@lists.plug.phoenix.az.us
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss