"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
As other people have stated wc -l is the easy way to go. But, if you want "lines" of code as in actual code statements, well, that gets a little more rough. Parsing out comments in C/C++ is not trivial. Page 293 of Mastering Regular Expressions, 1st Edition gives a regex that will remove multiline C comments ( /* */ style), but like I said, it is non-trivial. Furthermore, statements, themselves, could span multiple lines; thus, making a line count of non-comment lines be not indicative of how many statements of code are in a file.
So, I doubt it would be worth the effort to try and define statements of C/C++ code and count them. I would stick to wc -l. Jeremy In reply to Re: LOC
by enoch
|
|