/* FIXME FIXME */ /* * Very simple example of working with strings: * Find length of string two ways. */ #include /* return length of string s (working with it as an array) */ int slength1(char s[]) { int count = 0; while (s[count] != '\0') { ++count; } return count; } /* return length of string s (working with it using pointers) */ int slength2(char* s) { int count = 0; while (*(s++) != '\0') { ++count; } return count; } /* test length functions */ void test_both(char* s) { printf("computing length of '%s'\n", s); printf("%d with slength1\n", slength1(s)); printf("%d with slength2\n", slength2(s)); puts(""); } /* main program with some simple tests */ int main(void) { test_both(""); test_both("hello world"); return 0; }