How to count line of code in text file or file .cpp
(this .txt file or .cpp file is the input file of program)
and what's function for count line of only mark code
for example of this code(file input) , I want to count only "do" function that have mark //DO
The answers of program for read this code have to show "4"
#include <stdio.h>
int main ()
{
FILE * pFile;
int c;
int n = 0;
pFile=fopen ("1818.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
{
do { //DO
c = fgetc (pFile);
if (c == '$') n++;
} //DO
while (c != EOF);
fclose (pFile);
printf ("File contains %d$.\n",n);
}
return 0;
}
what's the source code for count the line of code and the line of each function
,Thank you