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
Oxana [17]
3 years ago
5

Write the following function without using the C++ string class or any functions in the standard library, including strlen(). Yo

u may use pointers, pointer arithmetic or array notation.Write the function lastOfAny().The function has two parameters (str1, str2), both pointers to the first character in a C-style string.You should be able to use literals for each argument.The function searches through str1, trying to find a match for any character inside str2.Return the index of the last character in str1 where this occurs.
Computers and Technology
1 answer:
dolphi86 [110]3 years ago
4 0

Answer:

The function in C++ is as follows

int chkInd(string str1, string str2){    

int lenstr1=0;

while(str1[lenstr1] != '\0'){  lenstr1++;  }

int index = 0; int retIndex=0;

for(int i=lenstr1-1;i>=0; i--){

   while (str2[index] != '\0'){

       if (str1[i] == str2[index]){

           retIndex=1;

           break;         }

       else{   retIndex=0;      }

  index++;    }

  if (retIndex == 0){   return i;   }else{return -1;}}

}

Explanation:

This defines the function

int chkInd(string str1, string str2){    

First, the length of str1 is initialized to 0

int lenstr1=0;

The following loop then calculates the length of str1

while(str1[lenstr1] != '\0'){  lenstr1++;  }

This initializes the current index and the returned index to 0

int index = 0; int retIndex=0;

This iterates through str1

for(int i=lenstr1-1;i>=0; i--){

This loop is repeated while there are characters in str2

   while (str2[index] != '\0'){

If current element of str2 and str1 are the same

       if (str1[i] == str2[index]){

Set the returned index to 1

           retIndex=1;

Then exit the loop

           break;         }

If otherwise, set the returned index to 0

       else{   retIndex=0;      }

Increase index by 1

  index++;    }

This returns the calculated returned index; if no matching is found, it returns -1

  if (retIndex == 0){   return i;   }else{return -1;}}

}

You might be interested in
Explain how buyers and sellers factor into setting the stock price for a company’s shares.
Kitty [74]

Answer:

The stock price of a company share depends upon the supply and demand. And demand is more if more buyers have positive intent towards the company services or end product. Also if the services and end product are trending, the more buyers buy them, and hence demand increases, and hence the value of the company shares, and hence the stock price.  

Explanation:

The stock price of a company share depends upon the supply and demand. And demand is more if more buyers have positive intent towards the company services or end product. Also if the services and end product are trending, the more buyers buy them, and hence demand increases, and hence the value of the company shares, and hence the stock price.  

Thus as mentioned above, the stock price is down when less buyers shows the intent to buy, and the demand hence is low. The sellers show interest only if demand is high, and sometimes if company sells for less amount and gives more profit margin.

6 0
3 years ago
The Huntington Boys and Girls Club is conducting a fundraiser by selling chili dinners to go. The price is $7 for an adult meal
sweet-ann [11.9K]

Answer:

Hi Um how do i create an answer/question on here? I have a question about aa qestion on my quiz

Explanation:

7 0
3 years ago
The two ways to use the help menu is by searching of the contents or searching the _____
Agata [3.3K]

The two ways to use the help menu is by searching of the contents or searching the index.

6 0
3 years ago
Read 2 more answers
How do you create a CA file? short answer
SashulF [63]

1.Create the root CA directory: mkdir -p /root/internalca cd /root/internalca.
2.Generate the private key of the root CA: openssl genrsa -out rootCAKey.pem 2048.
3.Generate the self-signed root CA certificate: ...
4.Review the certificate:
8 0
2 years ago
1. A database table can hold ??
IRINA_888 [86]

Answer:

who are interested and I have been trying to

3 0
2 years ago
Other questions:
  • When you arrive at work one morning, your inbox is full of messages complaining of a network slowdown. you collect a capture fro
    12·1 answer
  • Computer Architecture
    7·1 answer
  • A style manual can be described as
    11·2 answers
  • Write an expression to print each price in stock_prices. Sample output with inputs: 34.62 76.30 85.05
    9·1 answer
  • Which CSS attribute would change an element's font color to blue
    15·2 answers
  • 1) Identify at least four examples and uses of application software.​
    5·2 answers
  • When adjusting the aperture, an F-stop of F32 lets in more light then a setting of F8
    10·1 answer
  • A customer wants to increase his storage capacity by 25gb
    7·1 answer
  • When conducting memory and recall tests, some people make an effort to normalize memories by not reporting extreme cases. this l
    12·1 answer
  • What is the purpose of the GETPIVOTDATA function?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!