I am currently doing a practice problem for an upcoming exam,but I'm am unsure of what to do when the instruction says to "Return the pointer to the first appearance of c appearing inside s". So if anyone could point me in the right direction I would be very grateful.
You are given a char array, and can iterate over it by the following:
1 2 3 4
for ( int i = 0; i < strlen( s ); i++ )
{
cout << s[i]; //is the char at offset 'i'
}
, from here, you can determine the position of 'c' at 's'. Hope this helps.
Edit: Your return value is a pointer to this position in this array. If you're not sure how to return a pointer to that, check out pointer arithmetic: http://www.cplusplus.com/doc/tutorial/pointers/
Once again THANK YOU :D.I had forgotten to mention that the instruction forbids the use of C++ string class or C-style string functions in the standard library, including strlen() for the following function. Sorry about that that.