#!/bin/sh # This is a shar archive. # The rest of this file is a shell script which will extract: # # 3_1.c 3_1.cmp 3_1a.c 3_1b.c 3_1c.c 3_1c1.c 3_1c2.c 3_1c3.c 3_1c4.c 3_1tst.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:52 EDT 1990 # echo x - 3_1.c sed 's/^X//' > 3_1.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ int i = 0; while (i < max_length) { if (input_line[i] == '?') quest_count++; i++; } char *p = input_line; while (p < &input_line[max_length]) { if (*p=='?') quest_count++; p++; } !EOF! ls -l 3_1.c echo x - 3_1.cmp sed 's/^X//' > 3_1.cmp << '!EOF!' quest_count = 2 quest_count = 2 quest_count = 2 !EOF! ls -l 3_1.cmp echo x - 3_1a.c sed 's/^X//' > 3_1a.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ for (i=0; i 3_1b.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ i = 0; while ( i < max_length ) { if (input_line[i] == '?') quest_count++; i++; } !EOF! ls -l 3_1b.c echo x - 3_1c.c sed 's/^X//' > 3_1c.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ for (p = input_line; *p; p++) if (*p == '?') quest_count++; !EOF! ls -l 3_1c.c echo x - 3_1c1.c sed 's/^X//' > 3_1c1.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ p = input_line !EOF! ls -l 3_1c1.c echo x - 3_1c2.c sed 's/^X//' > 3_1c2.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ *p !EOF! ls -l 3_1c2.c echo x - 3_1c3.c sed 's/^X//' > 3_1c3.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ *p != 0 !EOF! ls -l 3_1c3.c echo x - 3_1c4.c sed 's/^X//' > 3_1c4.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ p++ !EOF! ls -l 3_1c4.c echo x - 3_1tst.c sed 's/^X//' > 3_1tst.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ #include main() { static char input_line[] = "Tom? Is that you Tom? I was so worried."; int max_length = sizeof(input_line) - 1; int quest_count = 0; int i = 0; #include "3_1a.c" cout << "quest_count = " << quest_count << "\n"; quest_count = 0; #include "3_1b.c" cout << "quest_count = " << quest_count << "\n"; char *p; quest_count = 0; #include "3_1c.c" cout << "quest_count = " << quest_count << "\n"; return 0; } !EOF! ls -l 3_1tst.c echo x - makefile sed 's/^X//' > makefile << '!EOF!' CC= CC -I. -I../../CC all: 3_1 3_1: 3_1a.c 3_1b.c 3_1c.c 3_1tst.c $(CC) 3_1tst.c -o 3_1 test: all 3_1.cmp 3_1 > 3_1.out cmp 3_1.out 3_1.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