#include
#include
using namespace std;
void main()
{
int IntValue[5] = {1,2,3,4,5};
int* Result;
Result = find(IntValue, IntValue+4, 8);
if (Result != IntValue+4)
{
cout<<"Result = "<<*Result<
{
cout <<"No corret result"<
while(1);
}
测试结果:
1) 数组存在相应的值,find() 函数将返回对应值
2) 数组不存在相应值,find() 将返回find 函数的第二个参数值,可以以此来判断数组的值中时候存在相应的值
摘自 DriverMonkey的专栏