Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C callable function that counts the number of characters in a string. The function should work for any string and character. The address

Write a C callable function that counts the number of characters in a string. The function should work for any string and character. The address of the string and character to be counted are passed as arguments according to the C function prototype:

extern int count(char *string, char c);

int main(void) { char s[100]; char c; printf("Enter a string of characters: "); scanf("%s", s); printf("Enter a character to count: "); scanf("%c", &c); printf(" The number of %c's in the string %s is %d ", c, s, count(s, c)); return 0; }

Please write the code in C. The function needs to be called as asked.

Examples

Please enter a character : Chegg

enter a character to count : g

Number of g = 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. 10.5b What is meant by the term depreciation tax shield?

Answered: 1 week ago

Question

2. How can competencies be used in employee development?

Answered: 1 week ago