1 #include<stdio.h>
2 #include<stdbool.h>
3
4 # define MAX_WORD_LENGTH 150
5
6 int main(int argc, char **argv) {
7 short int wordCountList[MAX_WORD_LENGTH];
8 const char TAB = '\t';
9 const char NEW_LINE = '\n';
10 const char SPACE = ' ';
11 char c;
12 bool wordStarted = false;
13 bool wordEnded = false;
14 short int wordCounted = 0;
15 short int index = 0;
16
17 printf("\nStart typing here ... ");
18
19 for (index = 0; index < MAX_WORD_LENGTH; index++) {
20 wordCountList[index] = 0;
21 }
22
23
24 while((c = getchar()) != EOF) {
25 if ((c == TAB || c == NEW_LINE || c == SPACE) && !wordStarted) {
26 continue;
27 } else if ((c != TAB || c != NEW_LINE || c != SPACE) && !wordStarted) {
28 wordStarted = true;
29 wordCounted++;
30 } else if ((c != TAB || c != NEW_LINE || c != ' ') && wordStarted) {
31 wordCounted++;
32 } else if ((c == TAB || c == NEW_LINE || c == SPACE) && wordStarted) {
33 wordEnded = true;
34 wordStarted = false;
35 wordCountList[wordCounted]++;
36 wordCounted = 0;
37 }
38 }
39
40 if (wordStarted && !wordEnded) {
41 wordEnded = true;
42 wordCountList[wordCounted]++;
43 }
Above is a c program on which I am trying to debug and it is not working as per expectation. At line number 30 how to check which of the OR condition was true, instead of printing the variable contents.