Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<time.h>
  3. #include<string.h>
  4.  
  5. char* myStrStr(const char *s1, const char *s2);
  6.  
  7. int main(){
  8. char* haystack = "I like to move it move it";
  9. char* needle = "move";
  10. clock_t start, end;
  11. double myStrTime;
  12. double stdStrTime;
  13.  
  14. start = clock();
  15. myStrStr(haystack, needle);
  16. end = clock();
  17. myStrTime = ((double) (end - start))/CLOCKS_PER_SEC;
  18.  
  19. start = clock();
  20. strstr(haystack, needle);
  21. end = clock();
  22. stdStrTime = ((double) (end - start))/CLOCKS_PER_SEC;
  23.  
  24. printf("Mine:%f\nStandard:%f\n", &myStrTime, &stdStrTime);
  25. printf("%d", myStrTime);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement