Date: Thu, 15 Dec 2005 16:47:17 -0500 From: Nicolas Blais <nb_root@videotron.ca> To: freebsd-questions@freebsd.org Cc: Vasilkov Vasily <chand0s@list.ru> Subject: Re: "fopen" call... Message-ID: <200512151647.23500.nb_root@videotron.ca> In-Reply-To: <op.s1ug66y1fi920b@lazy.lazy.org> References: <op.s1ug66y1fi920b@lazy.lazy.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On December 15, 2005 04:41 pm, Vasilkov Vasily wrote:
> Hi all..
> this is the part of my source
> ************
> FILE *source;
> source = fopen("/home/user/test.c", "r");
> if (source) {
> printf("fopen error");
> exit(0);
> };
> ************
> file "/home/user/test.c" exists and its access mode is 777..., but
> when I run program, I get "fopen error" message...
>
> Can anybody explain me this subj?
>
>
From man fopen:
RETURN VALUES
Upon successful completion fopen(), fdopen() and freopen() return a FILE
pointer. Otherwise, NULL is returned and the global variable errno is
set to indicate the error.
That means that your code should be:
FILE *source;
source = fopen("/home/user/test.c", "r");
if (!source) {
printf("fopen error");
exit(0);
};
Nicolas.
--
FreeBSD 7.0-CURRENT #4: Sat Dec 10 11:55:08 EST 2005
root@clk01a:/usr/obj/usr/src/sys/CLK01A
PGP? (updated 16 Nov 05) : http://www.clkroot.net/security/nb_root.asc
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (FreeBSD)
iD8DBQBDoeRr4wTBlvcsbJURAhYkAJwP3VrufI45tVFXGiAemoqfSwwX6wCeOY7t
JqbY/KlBLBHsKnCnZCPgPKE=
=QBzA
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200512151647.23500.nb_root>
