I am attempting to learn c programming.
I have written this small program:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
// variable declarations
long nc;
char ch;
// initialize variables
nc = 0;
while ((ch = getchar()) != EOF) {
printf("%d\t%c\n", ch, ch);
++nc;
}
printf("Number of characters typed: %ld\n", nc);
return EXIT_SUCCESS;
}
and I created a small text file like so:
echo "abcdef" > text.txt
When I run this program like so:
./countchar < text.txt
I get the following output:
97 a
98 b
99 c
100 d
101 e
102 f
10
Number of characters typed: 7
My question is what the 10 represents in this case (linefeed?) and why it appears as a seventh character when I have run this program using redirection.