Hi, im a beginner of programming c and this is an exercise from the book The C Programming Language by Bran W. Kernighan and Dennis M. Ritchie, exercise 1-8.
I am trying to simply count the spaces, tabs, new lines of an input. But the problem is, when i compile and run, then type something and enter, nothing comes up. just blanks.
Please find any mistakes or possible solutions!! Thanks.
Code:
#include<stdio.h>
main(){
int line=0,tab=0,space=0;
int input;
while ((input=getchar())!=EOF){
if (input=='\t'){
++tab;
}
if (input==' '){
++space;
}
if (input=='\n'){
++line;
}
}
printf ("%2d%2d%2d",space,tab,line);
}