#!/bin/sh # This is a shar archive. # The rest of this file is a shell script which will extract: # # 2_4.c 2_4.cmp 2_4a.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:56:46 EDT 1990 # echo x - 2_4.c sed 's/^X//' > 2_4.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ // print the sizes of all of the fundamental types #include #include "2_4a.c" /* EXPAND */ int main(int, char**) { pr("char", sizeof(char)); pr("short", sizeof(short)); pr("int", sizeof(int)); pr("long", sizeof(long)); pr("unsigned char", sizeof(unsigned char)); pr("unsigned short", sizeof(unsigned short)); pr("unsigned int", sizeof(unsigned int)); pr("unsigned long", sizeof(unsigned long)); pr("float", sizeof(float)); pr("double", sizeof(double)); pr("void *", sizeof(void *)); pr("char *", sizeof(char *)); pr("short *", sizeof(short *)); pr("int *", sizeof(int *)); pr("long *", sizeof(long *)); pr("unsigned char *", sizeof(unsigned char *)); pr("unsigned short *", sizeof(unsigned short *)); pr("unsigned int *", sizeof(unsigned int *)); pr("unsigned long *", sizeof(unsigned long *)); pr("float *", sizeof(float *)); pr("double *", sizeof(double *)); pr("int (*)()", sizeof(int (*)())); return 0; } !EOF! ls -l 2_4.c echo x - 2_4.cmp sed 's/^X//' > 2_4.cmp << '!EOF!' sizeof(char) = 1 sizeof(short) = 2 sizeof(int) = 4 sizeof(long) = 4 sizeof(unsigned char) = 1 sizeof(unsigned short) = 2 sizeof(unsigned int) = 4 sizeof(unsigned long) = 4 sizeof(float) = 4 sizeof(double) = 8 sizeof(void *) = 4 sizeof(char *) = 4 sizeof(short *) = 4 sizeof(int *) = 4 sizeof(long *) = 4 sizeof(unsigned char *) = 4 sizeof(unsigned short *) = 4 sizeof(unsigned int *) = 4 sizeof(unsigned long *) = 4 sizeof(float *) = 4 sizeof(double *) = 4 sizeof(int (*)()) = 4 !EOF! ls -l 2_4.cmp echo x - 2_4a.c sed 's/^X//' > 2_4a.c << '!EOF!' /* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */ /* The C++ Answer Book */ /* Tony Hansen */ /* All rights reserved. */ void pr(char *type, unsigned int size) { cout << "sizeof(" << type << ") = " << size << "\n"; } !EOF! ls -l 2_4a.c echo x - makefile sed 's/^X//' > makefile << '!EOF!' CC= CC -I. -I../../CC all: 2_4 2_4: 2_4.c 2_4a.c $(CC) 2_4.c -o 2_4 test: all 2_4.cmp 2_4 > 2_4.out cmp 2_4.out 2_4.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