strcmp implementation from scratch

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
tux4life tux4life is offline Offline May 22nd, 2009, 7:32 am |
0
This is how mine strcmp function would look like if I'd to implement it from scratch
Quick reply to this message  
C Syntax
  1. /**
  2. @author: Mathias Van Malderen (tux4life)
  3. */
  4.  
  5. int strcmp(const char *s1, const char *s2)
  6. {
  7. while((*s1 && *s2) && (*s1++ == *s2++));
  8. return *(--s1) - *(--s2);
  9. }
0
tux4life tux4life is offline Offline | May 28th, 2009
Yet to mention: I didn't include a NULL-pointer check
 
 

Message:


Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC