Professional Documents
Culture Documents
C Programming - File Summary - Write Co... - Chegg - Com1
C Programming - File Summary - Write Co... - Chegg - Com1
My Textbook Solutions
Expert Answer
Anonymous answered this
141 answers
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fptr;
fptr = fopen("E3-4.txt", "r");
if (fptr == NULL)
{
printf("\nCan't open file or file doesn't exist.");
exit(0);
}
int char_Count = 0;
int char_Count1 = 0;
int wrd_count = 0;
int line_count = 0;
int ch;
while ((ch = getc(fptr)) != EOF)
{
char x = (char)ch;
char_Count++;
if (x >= 'a' && x <= 'z')
char_Count1++;
if (x == ' ' || x == '\n')
{
wrd_count++;
}
if (x == '\n')
{
line_count++;
}
}
printf("Character count with all characters = %d\n", char_Count);
printf("Character count excluding the given characters = %d\n", char_Count1);
printf("Word count = %d\n", wrd_count);
printf("Line count = %d\n", line_count);
fclose(fptr);
return 0;
}
Show more
COMPANY LEGAL & POLICIES CHEGG PRODUCTS AND SERVICES CHEGG NETWORK CUSTOMER SERVICE
About Chegg Advertising Choices Cheap Textbooks Chegg Math Solver Easybib Customer Service
Chegg For Good Cookie Notice Chegg Coupon Mobile Apps Internships.com Give Us Feedback
College Marketing General Policies Chegg Play Solutions Manual Thinkful Manage Subscription
Corporate Development Intellectual Property Rights Chegg Study Help Study 101 Busuu
Investor Relations Terms of Use College Textbooks Textbook Rental Mathway
Jobs Global Privacy Policy eTextbooks Used Textbooks
Join Our Affiliate Program Cookies Settings Flashcards Digital Access Codes
Media Center Honor Code Learn Chegg Life
Site Map Honor Shield Uversity Chegg Writing
Academic Integrity