#!/bin/sh # This is a shar archive. # The rest of this file is a shell script which will extract: # # 2_13a.c 2_13a.cmp 2_13a1.c 2_13a2.c 2_13b.c 2_13b.cmp 2_13b1.c 2_13b2.c makefile # # To extract the files from this shell archive file simply # create a directory for this file, move the archive file # to it and enter the command # # sh filename # # The files will be extracted automatically. # Note: Do not use csh. # # Archive created: Mon Jul 30 22:55:29 EDT 1990 # echo x - 2_13a.c sed 's/^X//' > 2_13a.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include "2_13a1.c" #include "2_13a2.c" !EOF! ls -l 2_13a.c echo x - 2_13a.cmp sed 's/^X//' > 2_13a.cmp << '!EOF!' January 31 February 28 March 31 April 30 May 31 June 30 July 31 August 31 September 30 October 31 November 30 December 31 !EOF! ls -l 2_13a.cmp echo x - 2_13a1.c sed 's/^X//' > 2_13a1.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ char *months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; int days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; !EOF! ls -l 2_13a1.c echo x - 2_13a2.c sed 's/^X//' > 2_13a2.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // print the names and days of the months // version 1 #include int main(int, char**) { for (int i = 0; i < 12; i++) cout << months[i] << " " << days[i] << "\n"; return 0; } !EOF! ls -l 2_13a2.c echo x - 2_13b.c sed 's/^X//' > 2_13b.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include "2_13b1.c" #include "2_13b2.c" !EOF! ls -l 2_13b.c echo x - 2_13b.cmp sed 's/^X//' > 2_13b.cmp << '!EOF!' January 31 February 28 March 31 April 30 May 31 June 30 July 31 August 31 September 30 October 31 November 30 December 31 !EOF! ls -l 2_13b.cmp echo x - 2_13b1.c sed 's/^X//' > 2_13b1.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ struct { char *month; int day; } md[] = { { "January", 31 }, { "February", 28 }, { "March", 31 }, { "April", 30 }, { "May", 31 }, { "June", 30 }, { "July", 31 }, { "August", 31 }, { "September", 30 }, { "October", 31 }, { "November", 30 }, { "December", 31 } }; !EOF! ls -l 2_13b1.c echo x - 2_13b2.c sed 's/^X//' > 2_13b2.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // print the names and days of the months // version 2 #include int main(int, char**) { for (int i = 0; i < 12; i++) cout << md[i].month << " " << md[i].day << "\n"; return 0; } !EOF! ls -l 2_13b2.c echo x - makefile sed 's/^X//' > makefile << '!EOF!' CC= CC -I. -I../../CC all: 2_13a 2_13b 2_13a: 2_13a.c 2_13a1.c 2_13a2.c $(CC) 2_13a.c -o 2_13a 2_13b: 2_13b.c 2_13b1.c 2_13b2.c $(CC) 2_13b.c -o 2_13b test: all 2_13a.cmp 2_13b.cmp 2_13a > 2_13a.out cmp 2_13a.out 2_13a.cmp 2_13b > 2_13b.out cmp 2_13b.out 2_13b.cmp echo tests done !EOF! ls -l makefile # The following exit is to ensure that extra garbage # after the end of the shar file will be ignored. exit 0