4.3BSD-UWisc/lib/learn/C/L18.1a

#print
There is nothing to force you to write a main program
on each file; just as I supplied "getnum" on a separate file,
you can put different routines on different files.  Write
a function "length(s)" which if given a character array argument
"s" returns the length of that string.
Put this on a file named "length.c", and leave
the object file in "length.o".
Write the main program for
testing this somewhere else.  Type "ready" when you have compiled
and tested your program and are happy with it.
#once #create Ref
This file contains several lines of quite different lengths.

You should get
all of them exactly
r
right.
#once #create answer
60
0
14
19
1
6
#once #create tzaqc.c
main() {
	char s[200];
	while (gets(s))
		printf("%d\n", length(s));
}
#user
cc tzaqc.c length.c 
a.out <Ref >value
#cmp value answer
#succeed
/*	 one way */
length(s)
char *s;
{
	int k;

	for (k=0; s[k]; k++)
		;
	return(k);
}
#log
#next
19.1a 10