Hello, i cant find anything wrong with it, but it isnt working correctly:
Code:
#include <stdio.h>
/*count digits, white space, others */
main() {
int c, i, nwhite, nother;
int ndigit [10];
nwhite = nother = 0;
for(i = 0; i < 10; ++i){
ndigit[i] = 0;
}
while((c = getchar()) != EOF){
if(c >= '0' && c <= '9'){
++ndigit[c-'0'];
}
else if(c == ' ' || c == '\n' || c == '\t') {
++nwhite;
}
else{
++nother;
}
}
printf("digits =");
for(i = 0; i < 10; ++i) {
printf(" %d", ndigit[i]);
printf(", white space = %d, other = %d\n", nwhite, nother);
}
}
It compiles with no errors, but when i run it in cygwin, it is just like a regular input program, it comes up with no output, doesnt say how many words etc ar in it. This is the cygwin command bash:
Code:
Family_2@Family-PC ~
$ cd projects
Family_2@Family-PC ~/projects
$ ls
charcount count fahr helloworld input linecount vnc1l
Family_2@Family-PC ~/projects
$ cd count
Family_2@Family-PC ~/projects/count
$ ls
arrays.cpp arrays.exe charcount.cpp linecount.cpp wordcount.cpp
Family_2@Family-PC ~/projects/count
$ ./arrays
hello world
WTF?