#!/bin/sh # This is a shar archive. # The rest of this file is a shell script which will extract: # # 4_3a.c 4_3a1.cmp 4_3a2.cmp 4_3a3.cmp 4_3b.c 4_3b1.cmp 4_3b2.cmp 4_3b3.cmp 4_3c.c 4_3c1.cmp 4_3c2.cmp 4_3c3.cmp 4_3d.c 4_3d1.cmp 4_3d2.cmp 4_3d3.cmp 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 23:01:26 EDT 1990 # echo x - 4_3a.c sed 's/^X//' > 4_3a.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // print hello name #include #include int main(int argc, char **argv) { if (argc == 2) cout << "Hello, " << argv[1] << "\n"; else error("usage: hello name"); return 0; } !EOF! ls -l 4_3a.c echo x - 4_3a1.cmp sed 's/^X//' > 4_3a1.cmp << '!EOF!' !EOF! ls -l 4_3a1.cmp echo x - 4_3a2.cmp sed 's/^X//' > 4_3a2.cmp << '!EOF!' Hello, tony !EOF! ls -l 4_3a2.cmp echo x - 4_3a3.cmp sed 's/^X//' > 4_3a3.cmp << '!EOF!' !EOF! ls -l 4_3a3.cmp echo x - 4_3b.c sed 's/^X//' > 4_3b.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // print hello to a list of names // version 1 #include int main(int argc, char **argv) { for (int i = 1; i < argc; i++) cout << "Hello, " << argv[i] << "\n"; return 0; } !EOF! ls -l 4_3b.c echo x - 4_3b1.cmp sed 's/^X//' > 4_3b1.cmp << '!EOF!' !EOF! ls -l 4_3b1.cmp echo x - 4_3b2.cmp sed 's/^X//' > 4_3b2.cmp << '!EOF!' Hello, tony !EOF! ls -l 4_3b2.cmp echo x - 4_3b3.cmp sed 's/^X//' > 4_3b3.cmp << '!EOF!' Hello, tony Hello, hansen !EOF! ls -l 4_3b3.cmp echo x - 4_3c.c sed 's/^X//' > 4_3c.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // print hello to a list of names // version 2 #include int main(int argc, char **argv) { while (--argc > 0) cout << "Hello, " << *++argv << "\n"; return 0; } !EOF! ls -l 4_3c.c echo x - 4_3c1.cmp sed 's/^X//' > 4_3c1.cmp << '!EOF!' !EOF! ls -l 4_3c1.cmp echo x - 4_3c2.cmp sed 's/^X//' > 4_3c2.cmp << '!EOF!' Hello, tony !EOF! ls -l 4_3c2.cmp echo x - 4_3c3.cmp sed 's/^X//' > 4_3c3.cmp << '!EOF!' Hello, tony Hello, hansen !EOF! ls -l 4_3c3.cmp echo x - 4_3d.c sed 's/^X//' > 4_3d.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // print hello to a list of names // version 3 #include int main(int argc, char **argv) { if (argc > 0) while (*++argv != 0) cout << "Hello, " << *argv << "\n"; return 0; } !EOF! ls -l 4_3d.c echo x - 4_3d1.cmp sed 's/^X//' > 4_3d1.cmp << '!EOF!' !EOF! ls -l 4_3d1.cmp echo x - 4_3d2.cmp sed 's/^X//' > 4_3d2.cmp << '!EOF!' Hello, tony !EOF! ls -l 4_3d2.cmp echo x - 4_3d3.cmp sed 's/^X//' > 4_3d3.cmp << '!EOF!' Hello, tony Hello, hansen !EOF! ls -l 4_3d3.cmp echo x - makefile sed 's/^X//' > makefile << '!EOF!' CC= CC -I. -I../../CC ERROR= ../../error.o all: 4_3a 4_3b 4_3c 4_3d 4_3a: 4_3a.c $(CC) 4_3a.c -o 4_3a $(ERROR) 4_3b: 4_3b.c $(CC) 4_3b.c -o 4_3b $(ERROR) 4_3c: 4_3c.c $(CC) 4_3c.c -o 4_3c $(ERROR) 4_3d: 4_3d.c $(CC) 4_3d.c -o 4_3d $(ERROR) CMP= 4_3a1.cmp 4_3a2.cmp 4_3a3.cmp 4_3b1.cmp 4_3b2.cmp 4_3b3.cmp 4_3c1.cmp 4_3c2.cmp 4_3c3.cmp 4_3d1.cmp 4_3d2.cmp 4_3d3.cmp OUT= 4_3a1.out 4_3a2.out 4_3a3.out 4_3b1.out 4_3b2.out 4_3b3.out 4_3c1.out 4_3c2.out 4_3c3.out 4_3d1.out 4_3d2.out 4_3d3.out 4_3a1.out: 4_3a ; -4_3a 2> 4_3a1.out 4_3a2.out: 4_3a ; 4_3a tony > 4_3a2.out 4_3a3.out: 4_3a ; -4_3a tony hansen 2> 4_3a3.out 4_3b1.out: 4_3b ; 4_3b > 4_3b1.out 4_3b2.out: 4_3b ; 4_3b tony > 4_3b2.out 4_3b3.out: 4_3b ; 4_3b tony hansen > 4_3b3.out 4_3c1.out: 4_3c ; 4_3c > 4_3c1.out 4_3c2.out: 4_3c ; 4_3c tony > 4_3c2.out 4_3c3.out: 4_3c ; 4_3c tony hansen > 4_3c3.out 4_3d1.out: 4_3d ; 4_3d > 4_3d1.out 4_3d2.out: 4_3d ; 4_3d tony > 4_3d2.out 4_3d3.out: 4_3d ; 4_3d tony hansen > 4_3d3.out test: all $(OUT) $(CMP) cmp 4_3a1.out 4_3a1.cmp cmp 4_3a2.out 4_3a2.cmp cmp 4_3a3.out 4_3a3.cmp cmp 4_3b1.out 4_3b1.cmp cmp 4_3b2.out 4_3b2.cmp cmp 4_3b3.out 4_3b3.cmp cmp 4_3c1.out 4_3c1.cmp cmp 4_3c2.out 4_3c2.cmp cmp 4_3c3.out 4_3c3.cmp cmp 4_3d1.out 4_3d1.cmp cmp 4_3d2.out 4_3d2.cmp cmp 4_3d3.out 4_3d3.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