Date: Sun, 5 Jun 2005 14:57:46 +0200 From: Victor Balada Diaz <victor@bsdes.net> To: freebsd-hackers@freebsd.org Subject: Re: help me with C languaje please, re: files. Message-ID: <20050605125746.GB691@pato.euesrg02.net> In-Reply-To: <a9e342b50506042235372e2519@mail.gmail.com> References: <a9e342b505060411114e0fe3fd@mail.gmail.com> <20050604181730.GB49520@pato.euesrg02.net> <a9e342b50506042235372e2519@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jun 05, 2005 at 01:35:21AM -0400, Pablo Mora wrote: > #include <stdio.h> > #include <stdlib.h> > > int main(void) { > > FILE *p_to_f; > char buf[1024]; > int i, j = 0; > > p_to_f = fopen("test","r"); > > if(p_to_f == NULL) { > perror("fopen"); > exit(EXIT_FAILURE); > } > > for(i = 0; i < 4 && !feof(p_to_f); i++) { > fgets(buf,1024,p_to_f); > printf("%s", buf); > } > > fclose(p_to_f); > > return 0; > > } > > I expect that be well what I did. Thanks Victor. > > PD Corrigeme Si hay algo malo. :D You don't use j, in the for should be || instead of && and you don't check for errors in fgets. Btw, i think that this is not the best place for ask this questions, you should ask in a c programming list. -- La prueba mas fehaciente de que existe vida inteligente en otros planetas, es que no han intentado contactar con nosotros.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050605125746.GB691>