#!/bin/sh # This is a shar archive. # The rest of this file is a shell script which will extract: # # 3_4a.c 3_4a.cmp 3_4b.c 3_4b.cmp 3_4c.c 3_4c.cmp 3_4d.c 3_4d.cmp 3_4e.c 3_4e.cmp 3_4f.c 3_4f.cmp 3_4g.c 3_4g.cmp 3_4h.c 3_4h.cmp 3_4i.c 3_4i.cmp 3_4j.c 3_4j.cmp 3_4k.c 3_4k.cmp 3_4l.c 3_4l.cmp 3_4m.c 3_4m.cmp 3_4n.c 3_4n.cmp 3_4o.c 3_4o.cmp 3_4p.c 3_4p.cmp 3_4q.c 3_4r.c 3_4s.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:59:00 EDT 1990 # echo x - 3_4a.c sed 's/^X//' > 3_4a.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ geti() { static int i = 0; return ++i; } // . . . main() { /* DELETE */ printf("%d %d\n", geti(), geti()); return 0; } /* DELETE */ !EOF! ls -l 3_4a.c echo x - 3_4a.cmp sed 's/^X//' > 3_4a.cmp << '!EOF!' 1 2 !EOF! ls -l 3_4a.cmp echo x - 3_4b.c sed 's/^X//' > 3_4b.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ class x { int i; public: x() { i = 0; } next() { return ++i; } } y; // . . . #include /* DELETE */ main() { /* DELETE */ printf("%d %d\n", y.next(), y.next()); return 0; } /* DELETE */ !EOF! ls -l 3_4b.c echo x - 3_4b.cmp sed 's/^X//' > 3_4b.cmp << '!EOF!' 1 2 !EOF! ls -l 3_4b.cmp echo x - 3_4c.c sed 's/^X//' > 3_4c.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ main() { int i = /* DELETE */ printf("a") + printf("b") + printf("c"); printf("\n"); return 0; } /* DELETE */ !EOF! ls -l 3_4c.c echo x - 3_4c.cmp sed 's/^X//' > 3_4c.cmp << '!EOF!' abc !EOF! ls -l 3_4c.cmp echo x - 3_4d.c sed 's/^X//' > 3_4d.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ main() { int a, b; /* DELETE */ a = 3; b = a++ + ++a; printf("a=%d, b=%d\n", a, b); /* DELETE */ return 0; } /* DELETE */ !EOF! ls -l 3_4d.c echo x - 3_4d.cmp sed 's/^X//' > 3_4d.cmp << '!EOF!' a=5, b=8 !EOF! ls -l 3_4d.cmp echo x - 3_4e.c sed 's/^X//' > 3_4e.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ int v[3] = { 1, 2, 3 }; /* DELETE */ main() { int i; /* DELETE */ i = 0; v[i] = i++; printf("i=%d\n", i); /* DELETE */ printf("v[0]=%d, v[1]=%d, v[2]=%d\n", v[0], v[1], v[2]); /* DELETE */ return 0; } /* DELETE */ !EOF! ls -l 3_4e.c echo x - 3_4e.cmp sed 's/^X//' > 3_4e.cmp << '!EOF!' i=1 v[0]=0, v[1]=2, v[2]=3 !EOF! ls -l 3_4e.cmp echo x - 3_4f.c sed 's/^X//' > 3_4f.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ main() { int i = /* DELETE */ 1 << 18 ; printf("i=%#x\n", i); /* DELETE */ return 0; } /* DELETE */ !EOF! ls -l 3_4f.c echo x - 3_4f.cmp sed 's/^X//' > 3_4f.cmp << '!EOF!' i=0x40000 !EOF! ls -l 3_4f.cmp echo x - 3_4g.c sed 's/^X//' > 3_4g.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ main() { int i = /* DELETE */ 0100 << 1 ; printf("i=%#o\n", i); /* DELETE */ return 0; } /* DELETE */ !EOF! ls -l 3_4g.c echo x - 3_4g.cmp sed 's/^X//' > 3_4g.cmp << '!EOF!' i=0200 !EOF! ls -l 3_4g.cmp echo x - 3_4h.c sed 's/^X//' > 3_4h.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ main() { int i = /* DELETE */ 0100 >> -1 ; printf("i=%#o\n", i); /* DELETE */ return 0; } /* DELETE */ !EOF! ls -l 3_4h.c echo x - 3_4h.cmp sed 's/^X//' > 3_4h.cmp << '!EOF!' i=0 !EOF! ls -l 3_4h.cmp echo x - 3_4i.c sed 's/^X//' > 3_4i.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ main() { long i = /* DELETE */ -1L >> 3 ; printf("i=%#x\n", i); /* DELETE */ return 0; } /* DELETE */ !EOF! ls -l 3_4i.c echo x - 3_4i.cmp sed 's/^X//' > 3_4i.cmp << '!EOF!' i=0x1fffffff !EOF! ls -l 3_4i.cmp echo x - 3_4j.c sed 's/^X//' > 3_4j.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ #include /* DELETE */ main() { /* DELETE */ int c; read(1, (char*)&c, 1); printf("c=%#x\n", c); /* DELETE */ return 0; } /* DELETE */ !EOF! ls -l 3_4j.c echo x - 3_4j.cmp sed 's/^X//' > 3_4j.cmp << '!EOF!' c=0 !EOF! ls -l 3_4j.cmp echo x - 3_4k.c sed 's/^X//' > 3_4k.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ void xyz(int c) { /* DELETE */ static int i = 0; /* DELETE */ if (i++ > 20) /* DELETE */ exit(0); /* DELETE */ printf("c=%o\n", c); /* DELETE */ } /* DELETE */ main() { /* DELETE */ char c; while ((c = getchar()) != EOF) xyz(c); return 0; } /* DELETE */ !EOF! ls -l 3_4k.c echo x - 3_4k.cmp sed 's/^X//' > 3_4k.cmp << '!EOF!' c=141 c=142 c=143 c=144 c=145 c=146 c=147 c=150 c=12 c=377 c=377 c=377 c=377 c=377 c=377 c=377 c=377 c=377 c=377 c=377 c=377 !EOF! ls -l 3_4k.cmp echo x - 3_4l.c sed 's/^X//' > 3_4l.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ union { long a; struct { int b1 : 1; } b; } X; #include /* DELETE */ main() { /* DELETE */ X.b.b1 = 1; /* DELETE */ printf("a=%#x\n", X.a); /* DELETE */ return 0; } /* DELETE */ !EOF! ls -l 3_4l.c echo x - 3_4l.cmp sed 's/^X//' > 3_4l.cmp << '!EOF!' a=0x80000000 !EOF! ls -l 3_4l.cmp echo x - 3_4m.c sed 's/^X//' > 3_4m.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ char a[20] = "0123456789"; main() { /* DELETE */ int *a0 = (int*)&a[0]; int *a1 = (int*)&a[1]; int *a2 = (int*)&a[2]; int *a3 = (int*)&a[3]; cout << *a0 << *a1 << *a2 << *a3; return 0; } /* DELETE */ !EOF! ls -l 3_4m.c echo x - 3_4m.cmp sed 's/^X//' > 3_4m.cmp << '!EOF!' !EOF! ls -l 3_4m.cmp echo x - 3_4n.c sed 's/^X//' > 3_4n.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ main() { /* DELETE */ for (char a = 'i'; a <= 'j'; a++) cout << chr(a); return 0; } /* DELETE */ !EOF! ls -l 3_4n.c echo x - 3_4n.cmp sed 's/^X//' > 3_4n.cmp << '!EOF!' !EOF! ls -l 3_4n.cmp echo x - 3_4o.c sed 's/^X//' > 3_4o.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ main() { /* DELETE */ char *x = 0; cout << hex(*x) << "\n"; return 0; } /* DELETE */ !EOF! ls -l 3_4o.c echo x - 3_4o.cmp sed 's/^X//' > 3_4o.cmp << '!EOF!' 0 !EOF! ls -l 3_4o.cmp echo x - 3_4p.c sed 's/^X//' > 3_4p.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include /* DELETE */ int x[3] = { 2, 1, 0 }; int i = 0; /* DELETE */ main() { /* DELETE */ #define swap1(a,b) { int t = (a); (a) = (b); (b) = t; } #define swap2(a,b) { int t = (b); (b) = (a); (a) = t; } swap1(x[i], i); printf("i=%d, x[0]=%d, x[1]=%d, x[2]=%d\n", i, x[0], x[1], x[2]); /* DELETE */ x[0]=0; x[1]=1; i=0; /* DELETE */ #include "3_4r.c" /* DELETE */ printf("i=%d, x[0]=%d, x[1]=%d, x[2]=%d\n", i, x[0], x[1], x[2]); /* DELETE */ return 0; } /* DELETE */ !EOF! ls -l 3_4p.c echo x - 3_4p.cmp sed 's/^X//' > 3_4p.cmp << '!EOF!' i=2, x[0]=0, x[1]=1, x[2]=0 i=0, x[0]=0, x[1]=1, x[2]=0 !EOF! ls -l 3_4p.cmp echo x - 3_4q.c sed 's/^X//' > 3_4q.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ { int t = (x[i]); (x[i]) = (i); (i) = t; } !EOF! ls -l 3_4q.c echo x - 3_4r.c sed 's/^X//' > 3_4r.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ swap2(x[i], i); !EOF! ls -l 3_4r.c echo x - 3_4s.c sed 's/^X//' > 3_4s.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ { int t = (i); (i) = (x[i]); (x[i]) = t; } !EOF! ls -l 3_4s.c echo x - makefile sed 's/^X//' > makefile << '!EOF!' CC= CC -I. -I../../CC all: 3_4a 3_4b 3_4c 3_4d 3_4e 3_4f 3_4g 3_4h 3_4i 3_4j 3_4k 3_4l 3_4m 3_4n 3_4o 3_4p 3_4a: 3_4a.c ; $(CC) 3_4a.c -o 3_4a 3_4b: 3_4b.c ; $(CC) 3_4b.c -o 3_4b 3_4c: 3_4c.c ; $(CC) 3_4c.c -o 3_4c 3_4d: 3_4d.c ; $(CC) 3_4d.c -o 3_4d 3_4e: 3_4e.c ; $(CC) 3_4e.c -o 3_4e 3_4f: 3_4f.c ; $(CC) 3_4f.c -o 3_4f 3_4g: 3_4g.c ; $(CC) 3_4g.c -o 3_4g 3_4h: 3_4h.c ; $(CC) 3_4h.c -o 3_4h 3_4i: 3_4i.c ; $(CC) 3_4i.c -o 3_4i 3_4j: 3_4j.c ; $(CC) 3_4j.c -o 3_4j 3_4k: 3_4k.c ; $(CC) 3_4k.c -o 3_4k 3_4l: 3_4l.c ; $(CC) 3_4l.c -o 3_4l 3_4m: 3_4m.c ; $(CC) 3_4m.c -o 3_4m 3_4n: 3_4n.c ; $(CC) 3_4n.c -o 3_4n 3_4o: 3_4o.c ; $(CC) 3_4o.c -o 3_4o 3_4p: 3_4p.c 3_4r.c ; $(CC) 3_4p.c -o 3_4p CMP= 3_4a.cmp 3_4b.cmp 3_4c.cmp 3_4d.cmp 3_4e.cmp 3_4f.cmp 3_4g.cmp 3_4h.cmp 3_4i.cmp 3_4j.cmp 3_4k.cmp 3_4l.cmp 3_4m.cmp 3_4n.cmp 3_4o.cmp 3_4p.cmp OUT= 3_4a.out 3_4b.out 3_4c.out 3_4d.out 3_4e.out 3_4f.out 3_4g.out 3_4h.out 3_4i.out 3_4j.out 3_4k.out 3_4l.out 3_4m.out 3_4n.out 3_4o.out 3_4p.out 3_4a.out: 3_4a ; 3_4a > 3_4a.out 3_4b.out: 3_4b ; 3_4b > 3_4b.out 3_4c.out: 3_4c ; 3_4c > 3_4c.out 3_4d.out: 3_4d ; 3_4d > 3_4d.out 3_4e.out: 3_4e ; 3_4e > 3_4e.out 3_4f.out: 3_4f ; 3_4f > 3_4f.out 3_4g.out: 3_4g ; 3_4g > 3_4g.out 3_4h.out: 3_4h ; 3_4h > 3_4h.out 3_4i.out: 3_4i ; 3_4i > 3_4i.out 3_4j.out: 3_4j ; echo a | 3_4j > 3_4j.out 3_4k.out: 3_4k ; echo abcdefgh | 3_4k > 3_4k.out 3_4l.out: 3_4l ; 3_4l > 3_4l.out 3_4m.out: 3_4m ; -3_4m > 3_4m.out 3_4n.out: 3_4n ; 3_4n > 3_4n.out 3_4o.out: 3_4o ; 3_4o > 3_4o.out 3_4p.out: 3_4p ; 3_4p > 3_4p.out test: all $(CMP) $(OUT) cmp 3_4a.out 3_4a.cmp cmp 3_4b.out 3_4b.cmp cmp 3_4c.out 3_4c.cmp cmp 3_4d.out 3_4d.cmp cmp 3_4e.out 3_4e.cmp cmp 3_4f.out 3_4f.cmp cmp 3_4g.out 3_4g.cmp cmp 3_4h.out 3_4h.cmp cmp 3_4i.out 3_4i.cmp cmp 3_4j.out 3_4j.cmp cmp 3_4k.out 3_4k.cmp cmp 3_4l.out 3_4l.cmp cmp 3_4m.out 3_4m.cmp cmp 3_4n.out 3_4n.cmp cmp 3_4o.out 3_4o.cmp cmp 3_4p.out 3_4p.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