Wednesday, May 31, 2017

count.c (done)

#include<stdio.h>

int main (void)
{
    int a=0,b; int num; int o=0;
    long unsigned int charcount = 0;
    long unsigned int wordcount = 0;
    long unsigned int linecount = 0;
    while (a !=  EOF){
        a = getchar();
        if (!(a>='a' && a<='z') && !(a>='A' && a<='Z') && !(a == 39)){
            wordcount++;
            if (!(b>='a' && b<='z') && !(b>='A' && b<='Z') && !(b == 39)){
                wordcount--;
            }
        }
        if (a == '\n'){
            linecount++;
        }
        charcount++;
        b=a;
    }
    //wordcount =
    printf( "%lu %lu %lu\n", charcount-1, wordcount, linecount );
    return 0;
}

No comments:

Post a Comment