aboutsummaryrefslogtreecommitdiff
path: root/5.4.c
blob: a8ae1c4536ef1d57c85428c51dde98cb6aa2d39d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <string.h>

int strend(char *to, char *from);

int 
main(void)
{
  char str[] = "gnu linux";

  if(strend(str, "ux"))
    printf("yeahoooo\n");

  return 0;
}

int 
strend(char *to, char *from)
{
  size_t fsize = strlen(from);
  size_t tsize = strlen(to);

  if (tsize > fsize)
    to += tsize - fsize;
  else 
    return 0;


  while (*to++ == *from++ && *to != '\0' && *from != '\0')
    ;
  
  return (*from == '\0') ? 1 : 0;
}