35 lines
1.1 KiB
C
35 lines
1.1 KiB
C
#include "General.h"
|
|
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// SubString
|
|
// ---------
|
|
//
|
|
// General : Checks whether the second string is a sub string in the first string.
|
|
//
|
|
// Parameters :
|
|
// first_str - first a pointer of string (char *)
|
|
// second_str - second a pointer of string (char *)
|
|
//
|
|
// Return value : if the second string is a sub string in the first string (BOOLEAN).
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Programmer : Cohen Idan
|
|
// Student No : 211675038
|
|
// Date : 30.12.2019
|
|
//---------------------------------------------------------------------------------------
|
|
BOOLEAN SubString(char * first_str, char * second_str)
|
|
{
|
|
printf("s\n");
|
|
if (StringLength(first_str) < StringLength(second_str))
|
|
return (FALSE);
|
|
else
|
|
return (!StringCompare(second_str, first_str) ? (SubString(++first_str, second_str)) : TRUE);
|
|
}
|
|
|
|
void main(void)
|
|
{
|
|
string s1 = "ABCDEFG";
|
|
string s2 = "CD";
|
|
printf("%hu\n", SubString(s1, s2));
|
|
} |