Question: Need help needs to be running on Linux. Want the same input / output provided in the question. Thank you! greetings.txt hello how are you

Need help needs to be running on Linux. Want the same input / output provided in the question. Thank you!

Need help needs to be running on Linux. Want the same input

/ output provided in the question. Thank you! greetings.txt hello how are

greetings.txt

hello how are you i am good

countChar2.c

#include // define EOF

main(){

int c;

int count = 0;

c = getchar();

while(c != EOF) /* no end of file*/

{

count++; //include spaces and ' '

c = getchar(); /* read next */

}

printf("# of chars: %d ",count);

}

7. Problem F2 getchar, character comparison (15 pts) Specification The provided program uses getchar() to read input character by character, counting the number of characters from the standard input (keyboard or redirected from an input file). Modify the program so that it also counts the number of characters 'a' in the input. Implementation Name your program countchar2.c Hint: you might need to compare every character getchar reads in against the character 'a'. In Java or C, how to compare two characters? Sample Inputs/Outputs red 307 % gcc countChar2.c -o cc2 red 308 % cc2 hello how are you? I am good and Thanks! AD # of chars: 41 # of char 'a': 4 red 309 % cc2 hello how are you I am good AD # of chars: 28 # of char 'a': 2 red 310 % cc2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!