I am working on a project where I input a string, and it outputs that string on separate lines of the console. I have got that to work, but my question/error is when I am looking for a specific position of that word. An error message pops up regarding the "unsigned searcher = str.find("good");" with a red underline under "str" saying it needs a class identifier. I have looked online for examples but have no been able to solve this. Please help!
int _tmain(int argc, _TCHAR* argv[])
{
char str[] = " Hello good sirtttttt..!.";
char * pointer_char;
int pos = 0;
std::string str;
int i = 0;
int length = strlen(str);
string good; // word/char that i want to search
cin >> good;
for (i = 0; i < length; i++) //i<string size
{
unsigned searcher = str.find("good");
if (searcher != string::npos) {
cout << "found at : " << searcher;
}
}