A function called searcher that uses pointers

Assignment Help Computer Engineering
Reference no: EM132101937

Pointers

Task: Use pointers to compare two sets of characters, a source string and a charSet string.

Your program will include a function called searcher that uses pointers to both the source string and the character set, and which returns a pointer to a char.

The searcher function should use exactly this prototype (do not include any other parameters, and don't take advantage of any global variables in the searcher function):

char *searcher (char *source, char *charSet);

The basic idea is to locate the first character in the source string that matches any of the characters in the charSet string. The function then returns a pointer to the place in source where the first match was found.

If none of the characters in source match any of the chars in charSet, then a NULL pointer is returned. Note that you are searching for a single character, not a substring, although what you will print is a substring. The calling program should use the pointer returned from searcher.

For example:

Suppose source points to: ABCBGFE

(a) If charSet points to XYZ, then NULL is returned.

(b) If charSet points to XREQCF, then the function should return a pointer to the letter C in source; the substring CBGFE will be printed.

(c) If charSet points to FFGG, then the function should return a pointer to the letter G in source; the substring GFE will be printed.

(d) If charSet points to GBF, then the function should return a pointer to the first letter B in source; the substring BCBGFE will be printed.

Constraints: This program is intended to provide practice with pointers, so these limitations will apply:

You may not use any C-string or string object commands. For example, strcpy, strcmp, strlen, etc., are all off-limits.

You may not use array subscripts (brackets) anywhere in the searcher function. Use pointer notation rather than array notation in that function. However, the input function may read strings into array variables, i.e., into C-strings.

Processing: The program should be interactive. The user will provide a source string and also a character set string. The program should continue processing strings until the user signals for completion.

Output: After each search, print the following summary:

the source string

the charSet string

the address of the source string

the substring of the source string that starts at the position found by searcher if the search was successful, or print "unsuccessful search"

Reference no: EM132101937

Questions Cloud

Specific points of bentham moral theory : What are the specific points of Bentham's moral theory that J.S. Mill reconsidered in his formulation of utilitarianism?
Briefly summarize the tenets of existentialism : Briefly summarize the tenets of existentialism and share whether or not your own philosophy of life is compatible
Explore three different methods of calculating subnets : Explore at least three different methods of calculating subnets. (You can use the method presented in this book as one of your selections.)
What is the power density away from a directive antenna : What is the power density (in Watts) 30 km away from a directive antenna that has a transmitted power of 38 dBm and a directive antenna gain of 24 dB?
A function called searcher that uses pointers : Your program will include a function called searcher that uses pointers to both the source string and the character set, and which returns a pointer to a char.
Religion leader about religion diversity : What would be good question to ask a religion leader about religion diversity
How does art nourish the emotional part of us : He says that the emotional part of us is the inferior part. How does art nourish the emotional part of us?
View of the purpose of our existence in world : View of the body? View of the purpose of our existence in this world? View of knowledge?
Calculate the sum of all elements in the array : Populate an array that contains 100 random numbers between -100 and 100 Sort the array from largest to smallest .

Reviews

Write a Review

Computer Engineering Questions & Answers

  Suggest the other protection scheme which can be used more

for this assignment you will choose one of the following optionsoption 1 file access write a 2-page paper that

  How to modify the product program to use a gui

create the product Program to use a GUI. The GUI should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that..

  Discuss whether the buffer is a client or a server

Extend GDN by providing a graphical notation for monitors and monitor types. Discuss whether the BUFFER is a client or a server.

  List all winning teams from the al

Write a menu-driven program with the following options: List all winning teams from the AL. For a specific team, how many times were they in the World Series.

  What is the loaded characteristic impedance of the bus

A backplane stripline bus measures 15" from end to end. Six equally-spaced inputs circuits are wired to the bus, each of which has a loading capacitance.

  Design circuits for half and full subtractors

Design circuits for half- and full subtractors. The half-subtractor has two inputs and two outputs (DIFFERENCE and BORROW). The full sub-tractor has three input

  Define critical to the security posture of the organization

Security management practices, to include risk management, are very critical to the security posture of the organization

  Discuss the function of input and output devices

Discuss the function of input and output devices, and analyze the working principle of voice input and output systems with their present state of technology.

  Write ieee floating point representation of the following

Write IEEE floating point representation of the following decimal numbers.

  What changes to the process would you recommend

What changes to the process would you recommend? What are the key design principles that govern the effectiveness of this process?

  What should the given objectives be

You are a member of the Human Resources Department of a medium-sized organization that is implementing a new interorganizational system.

  Prepare an html document that describes an ordered list

Prepare and test an HTML document that describes an ordered list with the following contents: The highest level should be the names of your parents.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd