Table of Content
Added test driver for strlen function which comes from K&R C.
#include <stdio.h> #include <string.h> int strlen1(char s[]); /* test strlen function */ main() { char text[]="The power of C!" ; printf("The string: %s\n",text); printf("The length of string is %d - using strlen()\n", strlen(text)); printf("The length of string is %d - using strlen1()\n", strlen1(text)) ; return 0; } /* strlen: return length of s */ int strlen1(char s[]) { int i=0; while (s[i] != '\0') ++i; return i; }
test result:
$ strlen1 The string: The power of C! The length of string is 15 - using strlen() The length of string is 15 - using strlen1()