#include #include /* * File: * string.h * Author: * Samuel A. Rebelsky * Summary: * A host of simple tests of string procedures, intended as * an example for the spring 2003 session of Grinnell's * CSC195. (Also intended to help Sam write interesting lab * problems for that course.) * Version: * 1.0 of 14 February 2003 */ main() { int baboon; char sheep[8]; int cat; char chimpanzee[] = "animal"; char llama[7]; char gorilla[8]; char *antelope; char jackal[8] = "animal"; char koala[8] = "animal"; char lemur[8] = "animal"; printf("Test 1: Setting first letter of potentially-shared string.\n"); chimpanzee[0] = 'A'; printf("chimpanzee: '%s'\n", chimpanzee); printf("llama: '%s'\n", llama); printf("Test 2: Information about undeclared strings.\n"); printf("gorilla: '%s'\n", gorilla); printf("sizeof(gorilla): %d\n", sizeof(gorilla)); printf("strlen(gorilla): %d\n", strlen(gorilla)); strncat(koala,"ed", 2); printf("jackal: '%s'\n", jackal); printf("koala: '%s'\n", koala); printf("lemur: '%s'\n", lemur); exit(0); } /* main() */