How to check if a given substring within a string in C?
The code below compares whether they are equal, but if there is one inside the other.
#include <stdio.h>
#include <string.h>
int main( )
{
char str1[ ] = "test" ;
char str2[ ] = "subtest" ;
int i, j, k ;
i = strcmp ( str1, "test" ) ;
j = strcmp ( str1, str2 ) ;
k = strcmp ( str1, "t" ) ;
printf ( "\n%d %d %d", i, j, k ) ;
return 0;
}