#include <stdio.h>
#define YES 0
#define NO 0
int main()
{
int c, nl, nc, nw, tab;
nl = 0;
nc = 0;
nw = 0;
tab = NO;
while ((c = getchar()) != EOF)
{
++nc;
if (c == '\n')
++nl;
if (c == ' ' || c == '\t' || c == '\n')
tab = NO;
else if (tab == NO)
{
tab = YES;
++nw;
}
}
printf("NL: %d\nNC: %d\nNW: %d\n", nl, nc, nw);
}
Hey guys, new coder here. Actually, very much new, I just started a few days ago in hopes of broadening my job opportunities. Anyway, with this program, it counts every new line, word and character. For the most part, I understand what is going on but what I don't understand is the new word part. For example, at the top where we #define YES/NO, the number proceeding the word apparently does not matter? I swapped out 1 and 0 for so many other choices and yet still received the same outcome, why is that? Apologies in advance if this is a dumb question, for I myself am a dumb coder. Take care and thank you for your time!