Compare two sets of characters

Assignment Help Computer Engineering
Reference no: EM132101900

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 thecharSet 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: EM132101900

Questions Cloud

Explain when java object variables behave like pointer : Object variables in Java are a hybrid of pointer and reference variables. Use an example to show how to define an object variable in Java.
Create a new java application to manage linked lists : Create a new List (call it clockList) of type MyLinkedList . Insert five Clock objects numbers to the list (not ordered).
Create an array with thirty data elements : Suppose a data array has 30 numbers sorted from low to high already, where no two numbers are equal.
Why did the set timeout : IF i want to conect a raspberry pi 3 with a GSM modum through a serial port , and since the GSM modum is talking at 9600 (by datashet).
Compare two sets of characters : 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.
Calculate the number of possible color combinations : In the popular game Mastermind, one player creates a secret code of four pegs, each of which can be chosen from one of six colors.
Lists which enumerate coefcients of polynomials : The leading coeffcient of the output polynomial can not be zero. If the result is the zero polynomial, please output the empty list.
How many different 5-card poker hands are there : How many different 5-card Poker hands are there? How many of these are 1 pair?
Why do not the administrators just use random numbers : Why don't the administrators just use random numbers? Would these be the same for a proxy firewall? How would a NAC work with a firewall?

Reviews

Write a Review

Computer Engineering Questions & Answers

  What is the objective of unique labeling in real world

Why should labels be unique, what objective does unique labeling serve in real world? Why is assignment of accountability significant? What would be consequence of not having it?

  What potential advantages do optical processors offer

What potential advantages do optical processors offer compared with electrical processors?

  Briefly explain the idea behind the eigamal cryptosystem

Briefly explain the idea behind the EIGamal cryptosystem. What is the one-way function in this system? What is the trapdoor in this system?

  What is the gain of the antenna

A parabolic reflector has a diameter of 3m. If the antenna is 60% efficient, what is the gain of the antenna at 3GHz 300MHz 30 GHz?

  Explain how information systems can be used

Briefly describe the processes that are necessary for an organization to have a mass-customization capability. How does it relate to "micro marketing"? express the process known as General Electric Direct.

  Explain the limitations of the given technology

Of the numerous forms of communication technologies presented in this course, predict the first form of technology to be phased out by a newer and improved.

  Create a program that prompts a user for three numbers

Create the logic for a program that prompts a user for three numbers and stores them in an array. Pass the array to a method that reverses order of the numbers.

  What are the decision criteria for evaluating systems

How does the openness aspect of the organizational culture impact the system development decisions?

  Write a function named difference for the set class

Write a function named difference for the Set class that returns the difference between two sets. The function should return pointer to a new set that has item.

  Show the key code in the center of the screen

Write down a program that will display the hex code for any key, or key combination that is pressed on the keyboard. Display the key code in the center of the screen. For instance, if the key number 0 is pressed, display a 30 on the center of the ..

  Explain the sampling and non-sampling risks

Sampling and Non-sampling Risk. This module provided a detailed example of the use of sampling to determine whether individuals could increase their driving.

  Write a program that converts a temperature given

Write a program that converts a temperature given in Fahrenheit to Celsius. Allow the user to enter values for the original Fahrenheit value.

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