#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
int main()
{
unsigned long c;
unsigned long line;
unsigned long word;
char ch;
c = 0;
line = 0;
word = 0;
printf("Please enter text:\n");
while((ch = getchar()) != EOF)
{
c ++;
if (ch == '\n')
{
line ++;
}
if (ch == ' ' || ch == '\n')
{
word ++;
}
}
printf( "%lu %lu %lu\n", c, word, line );
return 0;
}
Right now my program works and it counts correctly for characters, words, and lines. But for words like That's, the program counts it as 1 word and I want it to count as 2 words. What would I need to add to account for that?
if(ch =='\'' || ch == ' ' || ch == '\n')
{
word++;
}