Created
December 17, 2013 15:57
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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