#include<stdio.h>
#include<string.h>
#define FAILE 1
#define SUCCESS 0
#include<assert.h>
int startswith(char *lhs, char * rhs)
{
assert(lhs!=NULL);
assert(rhs!=NULL);
while(* rhs)
{
if(*rhs++ != *lhs++)
return FAILE;
else
return SUCCESS;
}
}
int endswith(char* lhs, char* rhs)
{
assert(lhs!=NULL);
assert(rhs!=NULL);
lhs += strlen(lhs);
rhs += strlen(rhs);
while(*(--rhs))
if((*rhs) != *(--lhs))
return FAILE;
else
return SUCCESS;
}
int main()
{
char *s1 = "helloword";
char *s2 = "word";
char *s3 = "hello";
printf("%d\n",startswith(s1,s3));
printf("%d\n",endswith(s1,s2));
return 0;
}