For intcmp(a,b) why not just use a-b ? That will tell you if they are equal and if not, which is greater. For strcmp(s,t): while(*s++==*t++&&*s&&*t); return *s-*t;