Bond697

memcmp?

Aug 30th, 2011
419
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. u32_t memcmp()
  2. {
  3.  
  4. if(z == 0)
  5. {
  6.     return (z-1);  // return -1 if there's nothing to compare
  7. }
  8.  
  9. for(z = y; z >= 0; z--)
  10. {
  11.     if(*offset1 == *offset2)
  12.         {
  13.           offset1++;
  14.           offset2++;
  15.         }
  16.  
  17.     else
  18.         {
  19.           return (*offset1 - *offset2); // return the length into the compare that the difference started(if the 2 aren't the same)
  20.         }
  21. }  
  22.  
  23. return z; // return 0 if the compare was successful
  24. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment