Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int mystrend(char *s, char *c) {
  4. int sLen = 0;
  5. int cLen = 0;
  6.  
  7. while (*s != '\0') {
  8. s++, sLen++;
  9. }
  10.  
  11. while (*c != '\0') {
  12. c++, cLen++;
  13. }
  14.  
  15. if (cLen > sLen) {
  16. return 0;
  17. }
  18.  
  19. while (*s == *c) {
  20. if (cLen == 0) {
  21. return 1;
  22. }
  23.  
  24. s--, c--, cLen--;
  25. }
  26.  
  27. return 0;
  28. }
  29.  
  30. int main() {
  31. printf("%d\n", mystrend("abcd", "bd"));
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement