In my program, I have to input a word and then a character. The program will tell me how many times does the character appear in the word...my problem is that I have to find this character with the find(str,ind)...I know the ind is the index and can be manipulated with a loop...but what about the "str" part of it? I know that's where the character should be, so can I put the name of the variable in which the char is stored?

Don't you mean you need to use std::string's find() method? e.g.

std::string word = "Hello";
size_t pos = word.find('.', 0);

In the above, just put it in a loop and replace the second parameter to find() with the variable pos that was returned by the previous find. Keep doing that until find returns string::npos.

Yes, there is an overload which takes a char.

A good reference:http://www.cplusplus.com/reference/string/string/find/

EDIT: AD's got it ^^^^^^^^^ (but that site is still a good reference)

Ok, that helped a lot...thanks AD..and thanks for the reference jonsca.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.