A possible solution according to the requirements set could be:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define STRING_ARRAY_LENGTH 5
bool findString(std::string original, std::string search)
{
std::string::size_type foundPosition;
std::transform(original.begin(), original.end(), original.begin(), ::tolower);
std::transform(search.begin(), search.end(), search.begin(), ::tolower);
foundPosition = original.find(search);
return foundPosition != std::string::npos;
}
int main(void)
{
std::string* myStringCollection = new std::string[STRING_ARRAY_LENGTH]
{
"this is tom",
"tom and jerry is a cartoon show",
"i am BS Computer science student",
"Tom cruise is my favorite actor",
"C++ is a object-oriented language"
};
int myStringIndex = 0;
std::string mySearchString("tom");
while(myStringIndex < STRING_ARRAY_LENGTH)
{
if ( findString(myStringCollection[myStringIndex], mySearchString) )
std::cout << myStringCollection[myStringIndex] << std::endl;
myStringIndex++;
}
return 0;
}
NOTE: This example was compiled in gcc.
JAFC