1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
erica [24]
3 years ago
5

Assign a pointer to any instance of searchChar in personName to searchResult.#include #include using namespace std;int main() {c

har personName[100];char searchChar;char* searchResult = nullptr;cin.getline(personName, 100);cin >> searchChar;/* Your solution goes here */if (searchResult != nullptr) {cout << "Character found." << endl;}else {cout << "Character not found." << endl;}return 0;}

Computers and Technology
1 answer:
Firlakuza [10]3 years ago
8 0

Answer:

Here it the solution statement:

searchResult = strchr(personName, searchChar);

This statement uses strchr function which is used to find the occurrence of a character (searchChar) in a string (personName). The result is assigned to searchResult.

Headerfile cstring is included in order to use this method.

Explanation:

Here is the complete program

#include<iostream> //to use input output functions

#include <cstring> //to use strchr function

using namespace std; //to access objects like cin cout

int main() { // start of main() function body

   char personName[100]; //char type array that holds person name

   char searchChar; //stores character to be searched in personName

   char* searchResult = nullptr; // pointer. This statement is same as searchResult  = NULL  

   cin.getline(personName, 100); //reads the input string i.e. person name

   cin >> searchChar;    // reads the value of searchChar which is the character to be searched in personNa,e

   /* Your solution goes here */

   searchResult = strchr(personName, searchChar); //find the first occurrence of a searchChar in personName

   if (searchResult != nullptr) //if searchResult is not equal to nullptr

   {cout << "Character found." << endl;} //displays character found

   else //if searchResult is equal to null

   {cout << "Character not found." << endl;} // displays Character not found

   return 0;}

For example the user enters the following string as personName

Albert Johnson

and user enters the searchChar as:

J

Then the strchr() searches the first occurrence of J in AlbertJohnson.

The above program gives the following output:

Character found.

You might be interested in
Google’s adwords system provides a quality score as a measure of _____, which indicates the usefulness of an ad message to consu
Vanyuwa [196]
The term that best fit the blank is RELEVANCE. The Google Adwords system is a system that is created by Google for the purpose of advertising online. Therefore, relevance is very important in this aspect as this shows how useful the ad is to the consumers who are doing the google search.
3 0
3 years ago
Which of these is a benefit of using the Sort option?​
Reika [66]

There are many benefits of using the shot options in Excel. Some benefits are allowing you to short by number,date,color, letter, columns,or text. This benefits the user because it allows the user to bring data up more easily.

I hope this answers is helpful

3 0
3 years ago
3. Which of the following is a single piece of information related to the person, place,
stepan [7]
I think the answer is field
8 0
3 years ago
Read 2 more answers
What TCP message will be generated for an incoming SYN request for which is there no matching LISTENING port
tresset_1 [31]

Answer:

"Connection Refused"

Explanation:

This is the error message that is returned when the server is not listening on the correct port, or the server is offline.

Cheers.

7 0
2 years ago
The feedforward part of the conversation should do all of the following except __________.a.identify the toneb.introduce the pur
polet [3.4K]

Answer:

give leave taking clues

Explanation:

The feed forward part of the conversation should do all of the following except <u>give leave taking clues</u> a identify the tone introduce the purpose give leave-taking clues establish a time-frame

3 0
3 years ago
Other questions:
  • What is a flash player?
    9·2 answers
  • Briefly describe the client/server model.
    8·1 answer
  • When a computer is booted the checks the computer's components?
    7·1 answer
  • If 15 bits are sent in 3 seconds then Bits intervalis__________
    13·1 answer
  • Which component is a part of the CPU of a computer
    12·2 answers
  • Check my work a(n) ________ reference is an automatically created variable that holds the address of an object and passes it to
    15·1 answer
  • Write a class Example() such that it has a method that gives the difference between the size of strings when the '-' (subtractio
    6·1 answer
  • What's the inputs and outputs in a kitchen?
    14·1 answer
  • To reduce the potential for repetitive stress injury you should use proper?
    6·1 answer
  • Who are all the fnaf characters?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!