Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1.  
  2. #define ALLOC(A, Size) if (((A) = realloc((A), (Size))) == NULL) return 0
  3.  
  4.  
  5. int SentenceGetSubStrMaxLen(char *text1)
  6. {
  7. int MaxSize = 0;
  8. for (int i = 0; i < strlen(text1); ++i)
  9. {
  10. int Size = 0;
  11. char *Substr = NULL;
  12. while (i + Size < strlen(text1))
  13. {
  14. ALLOC(Substr, sizeof(wchar_t) * (Size + 1));
  15. memcpy(Substr, text1 + i, sizeof(wchar_t) * (Size + 1));
  16. Substr[Size] = 0;
  17. if (strstr(text1 + i + Size, Substr) != NULL)
  18. Size++;
  19. else
  20. {
  21. free(Substr);
  22. Substr = NULL;
  23. Size--;
  24. break;
  25. }
  26. free(Substr);
  27. Substr = NULL;
  28. }
  29. MaxSize = (Size > MaxSize) ? Size : MaxSize;
  30. }
  31. return MaxSize;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement