Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed
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

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions