C/C++ Arena

Step 2 of 6

strlen and friends

<string.h> has the standard string functions:

Function Does
strlen(s) number of chars before '\0'
strcpy(dst, src) copy src into dst
strcat(dst, src) append src to dst
strcmp(a, b) 0 if equal, negative/positive otherwise

dst must be big enough, including room for the '\0'.

Your turn: read two words and print them joined with a - between, followed by the total length. Input de dust2 prints de-dust2 8.

Previous: The null terminator Next: Write your own strlen