Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started