EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff

Training Missions

Read Me First New
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking New
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra New

Knowledge Bank

Discussion Forums
Enigma Chat New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Enigma Zine
Downloads
Tools New

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Hakipedia: An open collaborative for all your information security needs.

The Urinal

Click Here To Vote For EG!

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site.

enigma group

enigma group

enigma group

enigma group

Enigma Group's Code Bank


Adds line numbers

By: mofm  -  Date Submitted: 2009-07-25 17:31:13

  1. /*
  2.  
  3. fileex1.c
  4.  
  5.  
  6.  
  7. Input a text file a line at a time and output the
  8.  
  9. contents to the screen together with the line number.
  10.  
  11.  
  12.  
  13. */
  14.  
  15.  
  16.  
  17. #include <stdio.h>
  18.  
  19. #include <stdlib.h>
  20.  
  21.  
  22.  
  23. FILE *fpin /* Define file pointer */
  24.  
  25. char file_name[13]
  26.  
  27.  
  28.  
  29. void process_files(void)
  30.  
  31. {
  32.  
  33. char buff[80]
  34.  
  35. int line_count
  36.  
  37.  
  38.  
  39. line_count=1
  40.  
  41. while(fgets(buff,80,fpin)!=NULL) /* Read in lines until EOF */
  42.  
  43. {
  44.  
  45. printf("%4d %s",line_count++,buff)
  46.  
  47. }
  48.  
  49. } /* End process_files */
  50.  
  51.  
  52.  
  53. void open_files(void)
  54.  
  55. {
  56.  
  57. printf("Enter filename : ")
  58.  
  59. scanf("%s",file_name)
  60.  
  61. if((fpin=fopen(file_name,"r"))==NULL) /* open file - with check */
  62.  
  63. { /* Display error on fail */
  64.  
  65. printf("Cannot open file %s",file_name)
  66.  
  67. exit(1)
  68.  
  69. }
  70.  
  71. } /* End open_files */
  72.  
  73. void main(void)
  74.  
  75. {
  76.  
  77. open_files()
  78.  
  79. process_files()
  80.  
  81. fclose(fpin)
  82. return 1
  83.  
  84. } /* End of main program */
  85.  
Return to ajax category list

Who's Online

416 Guests, 93 Users
7A69, ThaKeeper, hemiptera, Ausome1, zofy, sabre725, chrbarrol, dark_void, towncrown, EngGi235, blink_212, klesco, vapour, _InSane_, LordHelmet, BnE, N4g4c3N, th3punish3r, locust, c0re, iwanlearn, Anderl, ghostraider100, Ghostrider, eliking510, harsha2hack, NotMyOwn, Calumoo, MajorDeath, Rex_Mundi, bhoang93, r!v3rTw!ggz, jarlskov, invas10n, snozzberries, Nusquam-Redono-Sapientia, data, zeth, psychomarine, yuka, DnA-Ender, 454447415244, Ultraminor, T-Metal, antibubbles, raven001, aVoid, Psiber_Syn, sirEgghead, Protagoras, niggletandco, Vahakn, Chaplin, BinaryShinigami, zoegeorgica, hacker807, Red_beard, eviscerator, TheFender, InjectioN, totalnoob, Posix, obrigadoo, cul8er, Mcasdf, teehee, Ops, Protest123, Blizer, gabel, Marian, Edika, Nasrudin, dochaley, TheRetech, j0sh, kcaz, cool.nik, Sand, SaMTHG, fawk3s, rajabaja, avalor, hettoo, mat_2010, barbseven, daandeveloper33, tommy1092, Likantrop7, sajan619, Knuppel, Distorted, Bloodmaster25