From owner-freebsd-questions@FreeBSD.ORG Thu Dec 15 21:47:25 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9666016A422 for ; Thu, 15 Dec 2005 21:47:25 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id A907743D5F for ; Thu, 15 Dec 2005 21:47:24 +0000 (GMT) (envelope-from nb_root@videotron.ca) Received: from clk01a ([66.130.198.54]) by VL-MO-MR003.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0IRK001XH76ZLJX0@VL-MO-MR003.ip.videotron.ca> for freebsd-questions@freebsd.org; Thu, 15 Dec 2005 16:47:24 -0500 (EST) Date: Thu, 15 Dec 2005 16:47:17 -0500 From: Nicolas Blais In-reply-to: To: freebsd-questions@freebsd.org Message-id: <200512151647.23500.nb_root@videotron.ca> MIME-version: 1.0 Content-type: multipart/signed; boundary=nextPart2866146.lKyPuEgPZ5; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-transfer-encoding: 7bit References: User-Agent: KMail/1.8.3 Cc: Vasilkov Vasily Subject: Re: "fopen" call... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2005 21:47:25 -0000 --nextPart2866146.lKyPuEgPZ5 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On December 15, 2005 04:41 pm, Vasilkov Vasily wrote: > Hi all.. > this is the part of my source > ************ > FILE *source; > source =3D 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? > > =46rom man fopen: RETURN VALUES Upon successful completion fopen(), fdopen() and freopen() return a FI= LE 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 =3D fopen("/home/user/test.c", "r"); if (!source) { printf("fopen error"); exit(0); }; Nicolas. =2D-=20 =46reeBSD 7.0-CURRENT #4: Sat Dec 10 11:55:08 EST 2005 =20 root@clk01a:/usr/obj/usr/src/sys/CLK01A=20 PGP? (updated 16 Nov 05) : http://www.clkroot.net/security/nb_root.asc --nextPart2866146.lKyPuEgPZ5 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQBDoeRr4wTBlvcsbJURAhYkAJwP3VrufI45tVFXGiAemoqfSwwX6wCeOY7t JqbY/KlBLBHsKnCnZCPgPKE= =QBzA -----END PGP SIGNATURE----- --nextPart2866146.lKyPuEgPZ5--