From: "Steve Thompson" To: Subject: Re: Line Checking.. Date: Sat, 21 Nov 1998 11:01:15 -0500 Message-ID: <01be1568$2bb33720$LocalHost@pos> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0039_01BE153E.42DD2F20" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.71.1712.3 X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Reply-To: djgpp AT delorie DOT com This is a multi-part message in MIME format. ------=_NextPart_000_0039_01BE153E.42DD2F20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Try the following attachment... Hope this helps Steve -----Original Message----- From: Nate Eldredge Newsgroups: comp.os.msdos.djgpp To: djgpp AT delorie DOT com Date: Friday, November 20, 1998 8:25 PM Subject: Re: Line Checking.. >Jeff Johnson wrote: >> >> How Do I Chech To See How Mine Lines (Up/Down) A File Is? >> >> Like, say, >> >> --out.dat-- >> 1 >> 2 >> 3 >> 4 >> ---------- >> >> and i want my prog to tell me that there are 4 lines in that file, how do i >> do that?? > >Btw, you are reinventing the wheel. Get the textutils and look at the >`-l' option to `wc'. >-- > >Nate Eldredge >nate AT cartsys DOT com ------=_NextPart_000_0039_01BE153E.42DD2F20 Content-Type: application/octet-stream; name="List.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="List.c" #include #include main(int argc, char *argv[]) { int line; char buffer[256]; FILE *fp; if(argc<2) { fprintf(stderr,"\nProper Usage is: "); fprintf(stderr,"\n\nLIST filename.ext\n"); exit(1); } if((fp=fopen(argv[1],"r"))==NULL) { fprintf(stderr,"Error opening file, %s!", argv[1]); exit(1); } line=1; while(fgets(buffer,256,fp) !=NULL) fprintf(stdout,"%4d:\t%s",line++,buffer); fclose(fp); printf("\n\nThe total number of lines are %d",line-1); return 0; } ------=_NextPart_000_0039_01BE153E.42DD2F20--