C source lines in file

carver at trsvax.UUCP carver at trsvax.UUCP
Sat Aug 12 07:03:00 AEST 1989


> Does anyone have a program or a method of determing
> the number of C source lines in a source file?
> My assumption is that comments don't count as source
> lines unless the comment is on a line with code.

Try using the friendly UNIX 'awk' program and do a search for ';' and '}'.

This seemed to work very well for a project I had in school.  In addition,
you can search for comments, blank lines, declarations of variables, ect,
and come up with a few good measurements of complexity like percentages of
statements vs. total lines and the like.

Of course, all of this is for naught if you aren't in a UNIX envirnment.

Hope this helps.

David "carver" Forney 

---------------------------------------------------------------------

DISCLAIMER:  All of the views expressed are my own and do not necessarily
reflect those of my employer. 



More information about the Comp.lang.c mailing list