Advertisement
cd62131

string_index

Apr 2nd, 2014
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. int string_index(char *a, char *b) {
  4.   int i = 0;
  5.   while (*a && *b) {
  6.     a++; b++; i++;
  7.   }
  8.   return i;
  9. }
  10. int main(void) {
  11.   char a[] = "楽しいです";
  12.   char b[] = "楽しいですね";
  13.   int i = string_index(a, b);
  14.   int j;
  15.   printf("match: %d\n", i);
  16.   for (j = 0; j < i; j++) putchar(a[j]); puts("");
  17.   for (j = 0; j < i; j++) putchar(b[j]); puts("");
  18.   return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement