Help for fopen()
feng1 at bnl.gov
Wed Aug 1 14:31:05 UTC 2007
Please never mind. There is some problems with the Linux PC
that I use for data storage. Thanks to Joe and Angelo.
Angelo Fraietta wrote:
> Kate Feng wrote:
> > I must have missed some simple setup steps that
> > fopen() does not seem to work anymore.
> > fopen("mydir/test.dat","w") returns error 2 : "/* No such file or
> > directory */"
> > even though it does exist.
> > fopen("test.dat","w") returns a file descriptor and
> > no error message. However, "test.dat" does not exist.
> > Even if "test.dat" exists and is world writable, it
> > does not seem to respond to the following
> > fprintf(fp, "test\n");
> > fflush(fp);
> > fsync(fileno(fp));
> > fclose(fp);
> > The file still remains empty and untouched.
> First try this
> FILE* fp = fopen("/test.dat","w");
> if (fp)
> fprintf(fp, "test\n");
> /* Now reopen and read */
> fp = fopen("/test.dat","r");
> ... bla bla bla - you can do the read code and print to console
> What do you get? Is teh file still empty?
> Dr Angelo Fraietta
> A.Eng, A.Mus.A, BA(Hons), Ph.D.
> PO Box 859
> Hamilton NSW 2303
> Home Page
> There are those who seek knowledge for the sake of knowledge - that is
> There are those who seek knowledge to be known by others - that is VANITY
> There are those who seek knowledge in order to serve - that is LOVE
> Bernard of Clairvaux (1090 - 1153)
More information about the users