EG Information
Training Missions
Knowledge Bank
|
|
Enigma Group's Code Bank
Adds line numbersBy: mofm - Date Submitted: 2009-07-25 17:31:13 /*
fileex1.c
Input a text file a line at a time and output the
contents to the screen together with the line number.
*/
#include <stdio.h>
#include <stdlib.h>
FILE *fpin /* Define file pointer */
char file_name[13]
void process_files(void)
{
char buff[80]
int line_count
line_count=1
while(fgets(buff,80,fpin)!=NULL) /* Read in lines until EOF */
{
printf("%4d %s",line_count++,buff)
}
} /* End process_files */
void open_files(void)
{
printf("Enter filename : ")
scanf("%s",file_name)
if((fpin=fopen(file_name,"r"))==NULL) /* open file - with check */
{ /* Display error on fail */
printf("Cannot open file %s",file_name)
exit(1)
}
} /* End open_files */
void main(void)
{
open_files()
process_files()
fclose(fpin)
return 1
} /* End of main program */
|
| Return to
ajax category list |
|
|
Who's Online
483 Guests, 101 Users ckryptix, viper0i0, Diznablo, rabbidmind, asapong, Nasrudin, CollapsingWalls, mehtaparag, bitstrike, jnony, C, Nicid1, Nusquam-Redono-Sapientia, bazcrown, saifulfaizan, The End, Ultraminor, psychomarine, st3alth, themastersinner, pgmrlink, login, lionaneesh, ishkur88, mahraja, Mac, chekifr, gandalf88, Vap0r, t0ast, tantrum6226, BnE, Distorted, Psiber_Syn, Ausome1, invas10n, oldgoat, freedaysbecumei, BinaryShinigami, Rex_Mundi, Red_beard, Strobeflux, s0m3nak3dguy, Descent, teehee, machupicchu, Genetix, Anandarl, NotMyOwn, thegamerdude, Godzila, popo12341234, RedEvolution, velocity_b, myne17, teto111, aVoid, Central-Gsm, 1101, JackalReborn, InjectioN, h4lted, c0re, DisPater, markt4death, splatta, Jackowacko, saint556, Pyron2312, Azerion, howsens, white.hat.gone.bad, vazzilly, pwunkz, Ios, Inverted, QuarterCask, Infernoe11, deskata, cr4ck3rj4ck, Blizer, jasonmax, j0sh, gwenwavor, N4g4c3N, spizeyboy, Network X, Uino59, Jae Cee, ianFDK, saykov, medhaavee, zofy, demonkiller410, Stumble, SaMTHG, kishore, Raze, helasraizam, Venom1019, Jakabo |
| |
|
|
|
|
|