Circular File | CodeGuru

Circular File

When I wrote my first article on CodeGuru, Expandable, Data Type-Neutral Buffer Class, I realized that there are lot of people seeking the code for a circular file. Hence, I developed my own circular file implementation, and want to share this. Its interface is very simple. Everything basically revolves around the Addline(CString) method which you […]

Written By
CodeGuru Staff
CodeGuru Staff
Nov 14, 2000
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

When I wrote my first article on CodeGuru,

Expandable, Data Type-Neutral Buffer Class
,
I realized that there are lot of people seeking the code
for a circular file.
Hence, I developed my own circular file implementation, and want
to share this. Its interface is very simple. Everything basically
revolves around the Addline(CString) method which you use to
add a line at a time to the current file.

Constructors:


  • //Create New File with Name "default Log" with 100 Lines
    CCirFile();
    
  • //Create File with Name strFile Name But 100 lines
    CCirFile(char * strFileName);
    

  • //You can specify file Name and File Size
    CCirFile(char * ,int );
    

Functions


  • //All file initialization here
    int InitFile();
    
  • //You should call this function to add new line at start of file
    int AddLine( CString );
    

Limitations


  • It’s not a true circular file implementation.
    It adds each new line to the beginning of the file,
    and moves the remaining lines, truncating the last line

  • It’s slow and performance could be dramatically increased via
    the use of multiple threads.

Downloads

Download demo project – 28 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.