Question: Develop a solid understanding of C-strings, and how each std::string object is a wrapper around a C string Practice with pointer operations in C++, e.g.

  • Develop a solid understanding of C-strings, and how each std::string object is a wrapper around a C string

  • Practice with pointer operations in C++, e.g. dereferencing, treating them as arrays (and vice versa), etc.

  • You may not use any #include directives. Rather, take this opportunity to write pure C++, without the use of any library functions/classes/etc.

/** * Reverses a C-string in place (i.e., modifies the string itself). * * @param str the string to reverse * @return a pointer to the reversed string */ char *strrev(char *str) { // TODO } /** * Finds the first occurrence of the substring needle in the C-string haystack. The terminating null * chars ('\0') are not compared. * * @param haystack the string in which to search * @param needle the string for which to search * @return a pointer to the beginning of the located substring, or nullptr if the substring is not * found. */ const char *strstr(const char *haystack, const char *needle) { // TODO }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!