Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- //TASK 6
- int main ( void )
- {
- int charcount = 0;
- int wordcount = 0;
- int linecount = 0;
- int c;
- while ((c=getchar()) != EOF) {
- if ((c != ' ') && (c != '\n')) {
- //Adding to character count
- charcount++;
- }
- if ((c == ' ') || (c == '\n')) {
- //Adding to word count
- wordcount++;
- }
- if (c == '\n') {
- //Adding to line count
- linecount++;
- }
- }
- printf("%lu %lu %lu\n", charcount, wordcount, linecount);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement