c++ 문자열에서 특정 문자열을 찾을 때 std::string의 find 함수를 사용한다
주의해야 할 점은 찾고자 하는 값이 없을 경우 -1이 아닌 매우 큰 쓰레기 값을 반환한다.
따라서 아래와 같이 'string::npos'를 이용해야 한다.
string.find() 함수에서 찾고자 하는 문자열이 없으면 'string::npos'를 반환하게 된다.
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
string str;
int alp[26];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> str;
size_t nPos = str.find("GHOST");
if(nPos != string::npos) cout << "존재";
else cout << "존재하지 않음";
return 0;
}