Code problem in K&R tutrial
Hey guys I just started c programming reading K&R atm but I dont understand this code it says it counts characters but it doesnt output anything its like a notepad thingy there 2 codes acctually whish I dont understand thanks .......
Code:
#include <stdio.h>
/* count characters in input; 2nd version */
int main(void)
{
double nc;
for (nc=0; getchar() != EOF; ++nc);
printf("%.0f\n", nc);
return 0;
}
2nd code its while version
Code:
#include <stdio.h>
/* count characters in input; 1st version */
int main(void)
{
long nc;
nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
return 0;
}