Skip to content

Instantly share code, notes, and snippets.

@KorbenC
Created December 17, 2013 15:57
Show Gist options
  • Save KorbenC/8007208 to your computer and use it in GitHub Desktop.
Save KorbenC/8007208 to your computer and use it in GitHub Desktop.
Given 2 strings 'str' and 'word' determine if one is a substring of the other
#include<iostream>
#include<string>
using namespace std;
int main()
{
char * str ="This is a simple string";
char * word = "string";
char * test = strstr (str,word);
if(test)
{
cout << "is a substring." << endl;
}
else
{
cout << "not a substring." << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment