[ create a new paste ] login | about

Link: http://codepad.org/Wm1mYA1d    [ raw code | output | fork ]

C, pasted on Oct 16:
int strend(const char *str1, const char *str2);

int strend(const char *str1, const char *str2) {
   int i = 0; 
   while (*str1++ != '\0');

   while (*str2++ != '\0') {
      i++;
   }
   i++;

   while (*str2-- == *str1-- && i > 0) {
     i--;
   }

   return (i == 0);
}

int main() {
   char str[500] = "javascript";
   char str2[] = "script";

   int i = strend(str, str2);

   printf("%d\n", i);

   return 0;

}


Output:
1
1


Create a new paste based on this one


Comments: