Or, you can use strncpy to move the portion of the original string into a second one. You would need to add a second string and a second pointer:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
char *string1 = "ABCDEFGHIJKLMFIRSTSTUVWXYZABCDEFGHIJKLMSECONDTUVWXYZ";
char string2[52] = "Didn't work!";
char *location1, *location2;
location1 = strstr(string1, "LM");
if (location1)
printf("%s\n\n", location1+2);
location2 = strstr(location1+2, "LM");
if (location2)
printf("%s\n\n", location2+2);
if (location1 && location2)
strncpy(string2, location1+2, location2-(location1+2));
printf("%s\n\n", string2);
system("PAUSE");
return EXIT_SUCCESS;
}
Take Care,
Ed