Code:
#include<stdio.h>
void main()
{
long n;
char a;
n=0;
while((a = getchar()) != EOF) {
if(a == '\n')
++n;
}
printf("the number of lines is %ld", n);
}
I use this source code for counting the no. of lines in an article that will be typed in. But the problem is that when i use only two '\n', the result still comes out to be 3!!! I dont understand the mistake.. What am i doing wrong?