As I know there is a function in C++ string which performs substring search: string1.find(string2).
Is there any way to perform the same action in char? Below is my question:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
char a[]="hello world!";
char b[]="el";
//find substring b[] in a[]
}
let's say i need to find substring "el" in the string, is it possible to do that?
char *output = NULL;
output = strstr (a,b);
if(output) {
printf("String Found");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With