/*
 * Very simple example of working with strings:
 * Find length of string two ways.
 */
#include <stdio.h>

/* 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;
}

/* main program with some simple tests */
int main(void) {
	char s1[4] = { 'a', 'b', 'c', '\0' };
	char *s2 = "abcde";
	printf("%s %d %d\n", s1, slength1(s1), slength2(s1));
	printf("%s %d %d\n", s2, slength1(s2), slength2(s2));
	return 0;
}