Just to clarify, are you trying to find the longest common substring between the two strings? Or, are you trying to find the longest common word shared between the two strings (a word in this case defined as a series of alphanumeric characters separated by whitespace and punctuation). Is the comparison case-sensitive?
Load the two files into two deque<string> objects. Sort them by length of string (longest first). Find the first two matching strings. You may want to use a case-insensitive comparator.
If file size is an issue, use a single map<string,unsigned> to store the strings and the number of files it was found in. The map comparitor should sort by (1) number of files (two files comes first, one file comes second) then (2) length of string, longest first, and be case-insensitive. The first item in the map is your match, assuming it's value (number of files) is 2.