🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #4891

Re: beginnersprobleem C onder Linux

#4891
From: KLinZ
Date: Sun, 29 Jun 2003 10:39
31 lines
2090 bytes
KLinZ wrote:

Even een volledige recode:

#include <stdio.h>

int main () {
 FILE *fp_bgl;      /* file pointer to file being read   */
 int rd_cnt;        /* will tell how many *items* were actually read */
 char header[128];  /* first 128 bytes in header */

 fp_bgl=fopen("de_naam_van_mijn_bestand", "r");
 if(fp_bgl!=NULL) {
  printf ("file opened with FP_BGL= %p\n", fp_bgl);     /* op zich weinig
nuttige info */
  rd_cnt=fread(header, sizeof(header), 1, fp_bgl);
  printf ("Header has read %3d items\n", rd_cnt);
  fclose(fp_bgl);
 } else {
  printf ("bestand kon niet geopend worden\n");
 }

 return 0;
}

Merk op dat fread niet het aantal gelezen bytes teruggeeft, maar het aantal
succesvol gelezen 'items'. Je kunt die waarde dus gebruiken om te
controleren of het lezen gelukt is.

-- 
www.zenobits.com
Technical Details
Message-ID: <kkzLa.14169$KF1.277597@amstwist00>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!skynet.be!skynet.be!213.51.129.3.MISMATCH!newshub1.home.nl!home.nl!amsnews01.chello.com!amstwist00.POSTED!not-for-mail
References: <bdmcmq$ttr34$1@ID-177484.news.dfncis.de> <41zLa.14163$KF1.277497@amstwist00>

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: fcea4,6f05fc089e78a5f3
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-06-29 03:38:15 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!skynet.be!skynet.be!213.51.129.3.MISMATCH!newshub1.home.nl!home.nl!amsnews01.chello.com!amstwist00.POSTED!not-for-mail
From: "KLinZ" <klinz@NOSPAMzenobitsSPAMNO.com>
Newsgroups: be.comp.programming
References: <bdmcmq$ttr34$1@ID-177484.news.dfncis.de> <41zLa.14163$KF1.277497@amstwist00>
Subject: Re: beginnersprobleem C onder Linux
Lines: 32
Organization: Inc.
MIME-Version: 1.0
Content-Type: text/plain;
 charset="Windows-1252"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <kkzLa.14169$KF1.277597@amstwist00>
Date: Sun, 29 Jun 2003 12:39:37 +0200
NNTP-Posting-Host: 212.187.71.152
X-Complaints-To: abuse@chello.nl
X-Trace: amstwist00 1056883088 212.187.71.152 (Sun, 29 Jun 2003 12:38:08 MET DST)
NNTP-Posting-Date: Sun, 29 Jun 2003 12:38:08 MET DST