counting no. of input lines

#include<stdio.h>
#include<conio.h>

main()
{
int c, nl;
nl = 0;
while ((c = getchar()) != EOF)
if (c == '\n')
++nl;
printf("%d\n", nl);
getch();
}

not getting output!!
Your problem is that you don't know how to signal EOF from keyboard.

Try pressing Ctrl-Z and Enter.
1238yy
sdio21
asdiou23
^Z
3

yeah..you are right.. :P..thnx
Topic archived. No new replies allowed.