Not particularly a .net question but c, not exactly sure where is should go. Anyway, I am following some lessons in a book and I can not seem to get the statements following the while loop to execute. It seems like once I hit enter the program runs the while loop and ignores everything below it. Maybe this is a system issue? – I’m on mac os x 10.5 leopard with the dev tools from apple.
thanks
#include <stdio.h>
#define IN 1
#define OUT 0
/* count digits, white space and 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 == '\
' || c == '\ ') {
++nwhite;
} else {
++nother;
}
}
printf("digits =");
for(i = 0;i < 10; ++i) {
printf(" %d",ndigit[i]);
}
printf(", white space = %d, other = %d\
", nwhite, nother);
return 0;
}