Tuesday, 27 August 2013

Program do count blanks, tabs and newlines. its not correct tell me where i'm wrong

Program do count blanks, tabs and newlines. its not correct tell me where
i'm wrong

#include <stdio.h>
int main(void)
{
int c, blank, tab, lines;
int till = 0;
blank = tab = lines = 0;
while(till == 0)
{
c = getchar();
switch(c)
{
case ' ' :
blank++;
case '\t' :
tab++;
case '\n' :
lines++;
case 'EOF' : /* warning: multi-character character constant
[-Wmultichar] */
till = 1;
}
}
printf("Blanks :%d Tab :%d Lines :%d\n", blank, tab, lines);
return 0;
}
While i compile this code it persist this error : warning: multi-character
character constant [-Wmultichar] and how can we use EOF in SWITCH.

No comments:

Post a Comment