/* --------------------------------------------------------------------- ** Pencil and Paper Exercise 5: Copy and concatenate. ** --------------------------------------------------------------------- */ #include "tools.h" void main( void ) { int k; string p; char line[80] = ""; const string word[] = { " attention", "like", "sleep", "eat", "dogs " }; for (k=4; k>=0; --k) { strcat( line, word[k] ); if (k<4 && k>1) strcat( line, " and " ); } printf( "%s.\n", line ); strcpy( line, "I want to eat horses." ); strncpy( &line[10], "seek", 3); p = strrchr( line, 'r' ); *p = 'u'; puts( line ); }