Question: Problem 2 (20): Write a program that looks for a character in a string and prints the position of that character whenever it is found.

Problem 2 (20): Write a program that looks for a character in a string and prints the position of that character whenever it is found. " Your program will do the following: 1. Ask the user to enter a string no longer that 40 characters. a. If the user enters a larger string, your program will only accept the first 40 and ignore the remaining characters. b. You will accept a string from the user that can contain any printable character from the ascii table. ' 2. Ask the user for a character to search for. a. You will accept a character from the user that can contain 'any printable character from the ascii table. ' b. Your program will only search for characters in the English alphabet.' c. If the user enters characters not in the alphabet you will exit after _ . ._ ;.- notifying the user. 3. Your program will make all the letters in the string lowercase except character being search for. ' y 4. Your program will print output to show the offset 'of where it found the's character. You can use the function fgetslbuffer, 41, stdin); 1. buffer is: char 9&41]; 2. 41 is the maximum number of characters including the '\\0' character 3. stdin in the special device where the input is read from Alternatively, you can use scanfl" %40["\ ]s", buffer); 1. 40 is the maximum number of characters to retrieve from the buffer 2. ["\ ] is the scan set and tells scanf to read all characters until it sees the '\ ' character. When scanf retrieves the scanf it should stop reading input. In both cases you will need to purge the input buffer: _fpurge(stdin); You will also need #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
