#!/bin/sh
# This is a shar archive.
# The rest of this file is a shell script which will extract:
#
# 2_12.c 2_12.cmp 2_12a1.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:24 EDT 1990
#
echo x - 2_12.c
sed 's/^X//' > 2_12.c << '!EOF!'
/* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
/* The C++ Answer Book */
/* Tony Hansen */
/* All rights reserved. */
// print the size of a string array
#include <stream.h>
#include <string.h>

char Str[] = "a short string";

int main(int, char**)
{
    cout << "sizeof(Str)=" << sizeof(Str) << "\n";
    cout << "strlen(Str)=" << strlen(Str) << "\n";
    cout << "sizeof(\"a short string\")=" <<
	sizeof("a short string") << "\n";
    cout << "strlen(\"a short string\")=" <<
	strlen("a short string") << "\n";
    return 0;
}
!EOF!
ls -l 2_12.c
echo x - 2_12.cmp
sed 's/^X//' > 2_12.cmp << '!EOF!'
sizeof(Str)=15
strlen(Str)=14
sizeof("a short string")=15
strlen("a short string")=14
!EOF!
ls -l 2_12.cmp
echo x - 2_12a1.c
sed 's/^X//' > 2_12a1.c << '!EOF!'
/* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
/* The C++ Answer Book */
/* Tony Hansen */
/* All rights reserved. */
char str[] = "a short string";
!EOF!
ls -l 2_12a1.c
echo x - makefile
sed 's/^X//' > makefile << '!EOF!'
CC= CC -I. -I../../CC
all: 2_12

2_12: 2_12.c
	$(CC) 2_12.c -o 2_12

test: all 2_12.cmp
	2_12 > 2_12.out
	cmp 2_12.out 2_12.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
