title: Program to read a code and count the number of lines in it,do not include comments and blank lines in count
body: <p>I am trying to create a program which, given an input file, returns the count of all the lines of code in the input file, excluding blank lines and comment lines. I have written the following code, however I need help with how to exclude lines containing comments and blank lines.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
      int count;
      char ch;
      FILE *fptr;
      clrscr();
      fp=fopen("test.cpp","r");
      if(fp==EOF)
          {
          perror("Error:");
          }
      else
      {
          while(ch!=EOF)
          {
              ch=fgetc(fptr);
              if(ch=='\n')
                  count++;
              if(ch=='\\')
                  count--;
              if(ch=='\*')
                            {
                  while(ch!='*\')
                                      {
                      ch=fgetc(fptr);
                                      }
              }
          }
      printf("the lines in the code are %d\n",count);
      fclose (fptr)
      }
      getchar();
      return 0;
  }
  </code></pre>
  
  <p>How can I modify the above code so that blank lines and comment lines are not counted?</p>