#include #include int str·ncompare(char *l, intptr n, char *r) { int cl, cr; while(n-- > 0){ cl=*l++, cr=*r++; if(cl != cr) return cl-cr; if(!cl) return 0; } return *r ? -1 : 0; }