subject

Write the function findFirst(). The function has two parameters: a const char * s1 pointing to the first character in a C-style string, and a const char * s2. Return a pointer to the first appearance of s2 appearing inside s1 and nullptr (0) if s2 does not appear inside s. Here is the supporting file and please keep in mind we are working with c++ pointers and C-style strings/**CS 150 C-StringsFollow the instructions on your handout to complete the requested function. You may not use ANY library functions or include any headers, except for for size_t.*/#include // size_t for sizes and indexes WRITE YOUR FUNCTION BELOW THIS LINE function goes in here WRITE YOUR FUNCTION ABOVE THIS LINE These are OK after the function#include #include using namespace std;void CHECK(const char*, const char *, const string&);void studentTests(){cout << "Student testing. Add code in this function." << endl;cout << "" << endl;CHECK("Aardvark", "dv", "dvark");CHECK("Aardvark", "k", "k");CHECK("Aardvark", "rdv", "rdvark");CHECK("Aardvark", "arki", "nullptr");cout << endl;cout << "--done--" << endl;}int main(){studentTests();}#include void CHECK(const char * s1, const char * s2, const string& expected){string msg = "findFirst(\"" + string(s1) + "\", \"" + string(s2) + "\")";char d1[1024], d2[1024];strcpy(d1, s1);strcpy(d2, s2);auto p = findFirst(d1, d2);string actual = (p ? string(p) : "nullptr");if (expected == actual)cout << " + " + msg + "->OK" << endl;elsecout << " X " + msg + " expected<\"" + expected + "\">, found <\"" + actual + "\">" << endl;}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:40
You have a linux system that has a 1000gb hard disk drive, which has a 90gb partition containing an ext4 filesystem mounted to the / directory and a 4gb swap partition. currently, this linux system is only used by a few users for storing small files; however, the department manager wants to upgrade this system and use it to run a database application that will be used by 100 users. the database application and the associated data will take up over 200gb of hard disk space. in addition, these 100 users will store their personal files on the hard disk of the system. each user must have a maximum of 5gb of storage space. the department manager has made it very clear that this system must not exhibit any downtime as a result of hard disk errors. how much hard disk space will you require, and what partitions would you need to ensure that the system will perform as needed? where would these partitions be mounted? what quotas would you implement? what commands would you need to run and what entries to /etc/fstab would you need to create? justify your answers.
Answers: 3
question
Computers and Technology, 23.06.2019 03:50
Iam a bacterium. i cause stomach cramps and diarrhea. i am caused by eating rotten foodssuch as chicken, fish, or eggs. sometimes turtles carry my bacteria.what am i?
Answers: 2
question
Computers and Technology, 24.06.2019 07:00
Guys do you know sh27 cause he hacked me : ( pidgegunderson my old user
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
Under the home tab, where can a user find options to change the bullet style of an outline? in the slides group in the font group in the paragraph group in the drawing group
Answers: 1
You know the right answer?
Write the function findFirst(). The function has two parameters: a const char * s1 pointing to the f...
Questions
question
Mathematics, 18.10.2019 13:30
question
Mathematics, 18.10.2019 13:30