The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details. |
Home Strings and things Our Own Version of Find | ||
Our Own Version of Find
{ while (i<s.length()) { if (s[i] == c) return i; i = i + 1; } return -1; } Instead of invoking this function on an pstring, like the first version of find, we have to pass the pstring as the first argument. The other arguments are the character we are looking for and the index where we should start.
|
||
Home Strings and things Our Own Version of Find |