Solution for Exercise 18-3

ex1803

#include <stdio.h>
#include <string.h>

int main()
{
    char string[] = "Does this string make me look fat?";

    printf("The string \"%s\" has a size of %lu,\n",
            string,sizeof(string));
    printf("and a length of %lu\n",strlen(string));
    return(0);
}

Output

The string "Does this string make me look fat?" has a size of 35,
and a length of 34

Notes

* I hope you remembered to include the string.h header file to use the strlen() function.

* Oh, and like sizeof, the strlen() function returns a long unsigned int value.