[prev] [index] [next]

Exercise: Implementing string.h

C strings are arrays of bytes, terminated by '\0'.

Implement the following operations from the string.h library:

typdef char *String;

int strlen(const String s);
String strcpy(String dest, const String src);

Use indexed-based iteration for strlen() and pointer-based iteration for strcpy().

The const indicates that we do not intend to change the input string.