#include <stdio.h>
int main(int argc, constchar * argv[]) {
int blank = 0;
int tabs = 0;
int newlines = 0;
int c;
printf("Enter some text containing blanks, tabs and newlines: ");
while ((c = getchar()) != EOF) {
if (c == ' ')
++blank;
elseif (c == '\t')
++tabs;
elseif (c == '\n')
++newlines;
else
c = getchar();
}
printf("There are %d blanks in the text.\n", blank);
printf("There are %d tabs in the text.\n", tabs);
printf("There are %d newlines in the text.\n", newlines);
return 0;
}
As I already said... take a look at those lines and fix them.
while ((c = getchar()) != EOF)
So the loop is supposed to run until it reaches end of file.... Except this is stdin, console input. You'll never reach an end of file. That means this is an infinite loop.
1 2
else
c = getchar();
Why do you have this here at all? You're going to skip the next character if the current character isn't one of the things you're keeping track of? Does that make sense?