Surviving the Technical Interview
Dr. Dobb's Journal Fall 1998
By Jay Sutaria
int strlen (char *ptr) { int i = 0; if (ptr == NULL) { /* the real strlen doesn't handle this */ /* case, but I do! I return -1 */ return (-1); } while (*ptr++) != '\0') { i++; } return i; }
Example 3: Implementing strlen().
Copyright © 1998, Dr. Dobb's Journal