Guest User

Untitled

a guest
Feb 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4.  
  5. int main() {
  6. char a[] = "/segment1";
  7. char b[] = "/";
  8.  
  9. char *s1 = a;
  10. char *s2 = b;
  11.  
  12. while (*s1 && *s2 && (*++s1 == *++s2));
  13. printf ("%d %d %d %d\n", *s1, *s2, s1-a, s2-b);
  14. if (!((*s1 == 0 || *s1 == 47) && (*s2 == 0 || *s2 == 47))) { // unless both are at end of segment
  15. while(*s1-- != 47 && s1 > 0);
  16. }
  17. *s1 = 0;
  18. printf ("%d %d %d %d\n", *s1, *s2, s1-a, s2-b);
  19. printf ("align: %s\n", a);
  20. }
  21.  
  22. // ausgabe:
  23. 115 0 1 1
  24. -65 0 -176 1
  25. align: /segment1
Add Comment
Please, Sign In to add comment