Click here to Skip to main content
Licence 
First Posted 2 Apr 2006
Views 23,202
Bookmarked 11 times

C++ Win32 Command Line Tail - Made Easy

By | 2 Apr 2006 | Article
Tail Program - Similar to unix tail - I found tail programs - but not a good CUI project. It runs continuously and prints the last characters as soon as the file gets updated. Coding is very easy - and one can reuse and move further with it

Sample Image - Tail.jpg

Introduction

This is a command line tail program which prints the last updated characters of a file. One can use this to view the log files.

This program keeps on running and as soon as the file gets updated, the last characters are shown.

Usage

Tail [Absolute File Path]

Example:

tail c:\demo.txt
Above command shows the last characters of the file as soon as it is updated and waits again for the file to be updated

About The Code

Code is very simple - still some notes on it.

  • getftime - Small function to get the File Timestamp in character array.
  • getfnoc - Returns number of characters of a file
  • Logic: First I opened the file, got its timestamp and total characters present. Next in a loop - with sleep delay, i am checking the timestamp with initial one, and if there is diffrence, just printing the added characters and updating the variable for total characters. Thats All. Very Easy.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

kbfromindia

Web Developer

India India

Member

Hi, I am a simple programmer and try to make things as simple as possible.
 
I code in c++, vb, perl etc. and try making simple objects out of things which look very hard

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 2 PinmemberMember 37857014:21 4 Mar '09  
GeneralDon't work Pinmemberrobertomir2:11 19 May '07  
GeneralSome issues Pinmemberprcarp4:19 3 Apr '06  
GeneralRe: Some issues Pinmemberkbfromindia20:39 3 Apr '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 3 Apr 2006
Article Copyright 2006 by kbfromindia
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid