Click here to Skip to main content
15,867,686 members
Articles / Desktop Programming / MFC
Article

Counting Lines in a MS VC++ 6.0 project

Rate me:
Please Sign up or sign in to vote.
4.33/5 (15 votes)
4 Aug 2001 151.5K   1.9K   33   28
A program that counts the lines (source, comments, blank) in every file included in a MS VC++ 6.0 project

Sample Image - LineCounter.gif

Introduction

Ever wondered how many lines a project you have worked on for a month (or maybe for a year!)? Well, we did this for you :)

This program (LineCounter) was developed with one purpose only: to count your lines!

The program is able to count source code, comments (both styles: "// comment" and "/* comment */"), and blank lines. It shows the results in a couple of editboxes, and has a preview window (right click on the list).

The program opens the project file (.dsp) and throws it through the parsing code. After parsing is done the list of project files is steped-by-step and lines are counted.

That's it! The source code is pretty self explanatory, so I guess you'll manage.

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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalyour program is not counting lines correctly Pin
evilman1-Feb-03 9:33
evilman1-Feb-03 9:33 
Ok so I just wrote a simple FTP server and I wanted to know how much lines I used.
Anyway, it seems that your program doesn't count lines for all C++ styles. A file with 664 lines returned 0 lines in every fields. thats not normal.
The files that were counted incorrectly were not written by me, but they do compile.

Oh and I don't like your user interface. The menu's are simply not useful and there shouldnt be any Count item. simply count the lines on file open. Its just a waste of time for the poor user.
oh well.

heres a sample of my stack.cpp (which returns 0 lines, I can guarantee that its wrong):
<br />
#include "stack.h"<br />
<br />
int StackNotEmpty(stk_stack * theStack) {<br />
  return( theStack ? (int) theStack->top : 0);<br />
}<br />
<br />
stk_stack * StackJoin(stk_stack * stack1, stk_stack * stack2) {<br />
  if (!stack1->tail) {<br />
    free(stack1);<br />
    return(stack2);<br />
  } else {<br />
    stack1->tail->next=stack2->top;<br />
    stack1->tail=stack2->tail;<br />
    free(stack2);<br />
    return(stack1);<br />
  }<br />
}<br />

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

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