Sunday, August 2, 2009

C++ .find function?

I really need an example of an C++.find function.

C++ .find function?
wud u plz clear ur question
Reply:The others are correct. What is it you are trying to find?


I am going to guess.





boolean find(char x, char [] array)


{


For (int i=0; i %26lt; array.length, i++)


if (array[i]==x)


return true;//stops loop





return false;//if loop doesnt find x


}





You can return a true you found something or the something you wanted to find. usually position in life is everything, so you would return where it is. Knowing where it is, you can anything to it.
Reply:to find something, press Control %26amp; F.





for others, open microsoft word, and go to Edit- it usually shows a couple.
Reply:i asked the same question but here is my understanding on it:


#include %26lt;iostream%26gt;


#include %26lt;string%26gt;





using namespace std;





int main()


{


string str="try this";


cout %26lt;%26lt; str.find("this");


cout %26lt;%26lt; endl %26lt;%26lt; endl;











return 0;


}





this will display 4 because "this" starts at 4. at least thats what i know i could be wrong.


No comments:

Post a Comment