In C++, create a method that finds a character in a c style string using pointers

Question

Create a method that searches through str for the character chr. If the chr is found, it returns a pointer into str where the character was first found, otherwise nullptr (not found).

Explanation

findTheChar method has 2 parameters, an array of char, which is the c style string, and chr, which is the character to find in the string. Within the method, there is a for loop which iterates from 0 until a null terminator is…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store