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
Is a collection of information stored under a single name ​
oksian1 [2.3K]

\boxed{ File  } is a collection of information stored under a single name.

\bold{ \green{ \star{ \orange{Mystique35}}}}⋆

3 0
3 years ago
Read 2 more answers
In an attack known as ____, valid protocol packets exploit poorly configured dns servers to inject false information to corrupt
ra1l [238]
The answer is DNS Cache Poisoning

Also known as DNS spoofing, this is a type of attack that exploits the Domain Name System to divert traffic away to legitimate servers. It inserts corrupt data into the cache database of the DNS server. In this attack, a hacker sends forged responses from an imposter DNS with an intention to reroute a domain name to a new IP address. This new IP is almost always controlled by the hacker.

       




6 0
4 years ago
which type of group found in server 2008 is used to provide access to resources for all users and guests​
evablogger [386]

Answer:

Everyone

Explanation:

There are various types of groups found on the server 2008, and everyone is one out of them. Here we are required to provide them access to the resources to all the users as well as the guests. And hence, we need to provide all the access to the resources. Thus, the correct option here is certainly everyone, which is an option available in the server 2008.

5 0
4 years ago
The Internet may best be compared to a/an
Usimov [2.4K]
A volcano because its always erupting
3 0
3 years ago
Explain how arrays are stored in memory? Show how arr [5] is stored in the memory. Assume each memory location is one byte long
Black_prince [1.1K]

Explanation:

Array is collection of similar data types it is a linear data structure.Array stores elements in a contiguous memory location.

We have an array arr[5]  of size 5 and it is of integer type.Suppose the starting address of the array is 2000 and each memory location is one byte long.As we know that the size of integer is 2 or 4 bytes we take it 2 bytes.

If the starting address is 2000 that is of index 0 then the address of index 1 is 2000+2=2002.

address of index 2=2004.

address of index 3=2006.

address of index 4=2008.

Since size of int is 2 bytes hence we add two memory location.

8 0
3 years ago
Other questions:
  • Which database item would show details such as a customer’s name, their last purchase, and other details about a customer
    14·2 answers
  • ___________ is produced by propulsion systems or engines.
    6·1 answer
  • i see tabs named mowed and Ramsey i tried shredding them and deleting them and ending all the processes but they start duplicati
    13·1 answer
  • 2. Design a class named Sandwich with data fields for description and price. Include a constructor that requires arguments for b
    14·1 answer
  • System inputs and outputs are produced at the end of the: A. systems analysis phase of the SDLC. B. systems planning and selecti
    12·1 answer
  • What things have small motors
    13·1 answer
  • In object-oriented programming, the object encapsulates both the data and the functions that operate on the data.
    10·1 answer
  • If the floating-point number representation on a certain system has a sign bit, a 3-bit exponent, and a 4-bit significand. What
    8·1 answer
  • USE THIS CODE ON FETCH REWARDS FOR BRAINLIEST​
    10·1 answer
  • Which native windows application allows you to access basic pc settings and controls such as system information, controlling use
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!