Language/C

[C] strstr() 문자열 내검색함수!

퓨림노 2013. 5. 6. 02:19

strstr() 검색함수!

- 특정 글자 내부에 검색하고자 하는 글자가 있을 경우 사용!


#include 
#include 
using namespace std;

void main()
{
	char str1[30] = "pretty girl";
	char str2[20] = "girl";
	char *p;

	if( ( p = strstr(str1, str2) ) == NULL )
	{
		cout << "not found" << endl;
	}
	else 
	{
		cout << p << endl;
		cout << "found" << endl;
	}	
}