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 %u,\n",
            string,sizeof(string));
    printf("and a length of %ld.\n",strlen(string));
    return(0);
}

Notes

* For a Macintosh, or some other Unix variant, change the %u conversion character used in printf() at Line 8 to %ld.

* You need to include the string.h header file to use the strlen() function.

* Here is sample output: