Question: Q3) Write a program that counts the number of times a specific character occurs in a string. For example, if the string is hello world

 Q3) Write a program that counts the number of times a

Q3) Write a program that counts the number of times a specific character occurs in a string. For example, if the string is "hello world" and the character being counted is '1', the prgram should output 3. The output should follow the format below (there are NO double spaces). Enter the length of the string: 13 Enter the string: hello world Enter search character: Characters found: 3 Modify the code from the previous problem by changing the datatype of the array to char instead of int. The line with malloc must also be change to match the datatype. Do not sort the array. It may be beneficial to run sed '3d;9d;21,30d' sort.c> count-char.c to begin structuring your program. Another idea may be to copy the old code and modify the necessary lines, this is done by cp avg-var.c count_char.c. Note: Even though hello world" only has 11 letters (including the space), there is an addi- tional line feed character before and after the letters. Thus, the total size of the string is the number of letters + 2. Name your file count_char.c

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!