The source code for pig.c may be downloaded. The purpose of this program is to demonstrate the use of C strings of ASCII characters. Each string is "terminated" (i.e. ends) with a NUL character (which has the value 0x00).
You type> cat pig.c main() { /* create an array of characters */ char str1[9]; str1[0]='p'; str1[1]='i'; str1[2]='g'; str1[3]=0; printf("The animal is a %s\n",str1); } you type> cc -o pig pig.c you type> pig The animal is a pig
BACK to index page.
(Now check "Dog" if you haven't already done so).