Home » Archimedes archive » Acorn User » AU 1995-03.adf » !C_C » c/Kate4

c/Kate4

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1995-03.adf » !C_C
Filename: c/Kate4
Read OK:
File size: 0DBC bytes
Load address: 0000
Exec address: 0000
File contents
/* Kate 4: the fourth fragment of the grand photo-cataloguing program.   *
 * Include header files to define functions for I/O and string handling. */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/* First function. This reads in all the arrays in one go. *
 * The array returns an integer equal to the number of     *
 * frames read, to allow for expansion to cope with the    *
 * circumstance when a user aborts the read halfway        *
 * through. The arrays are passed to the function as       *
 * pointers rather than being copieds. Any changes to the  *
 * arrays in the function will therefore change the arrays *
 * in main(), since they occupy the same address space.    *
 * The number of exposures on the film is passed as an     *
 * integer n. In this case it is a copy of n that is       *
 * passed, so any changes to n in readfilm() will not      *
 * affect the variable in main().                          */

int readfilm(int aperture[40][2], int *exposure, char *place[40], int n)
{ int i, len;
  float datum;
  char buffer[256];

  printf("You will now be asked to enter exposure, aperture and\n");
  printf("location data for each frame on the film.\n");
  printf("If the exposure is less than one second, it should be\n");
  printf("entered as minus the reciprocal of the exposure. For\n");
  printf("instance, an exposure of a thirtieth of a second should\n");
  printf("be entered as \"-30\".\n");
  printf("All locations should be shorter than 255 characters long.\n");

  for (i=0; i<n; i++)
  { printf("Please enter the exposure of frame %d.\n",i);
    scanf("%d",&exposure[i]);
    printf("Please enter the aperture setting for frame %d.\n",i);
    scanf("%f",&datum);
    aperture[i][0] = (int)datum;
    aperture[i][1] = (datum - aperture[i][0]) * 10;
    printf("Please enter the loction for frame %d.\n",i);
    getchar();
    gets(buffer);
    len = strlen(buffer);
    place[i] = malloc(len+1);
    strcpy(place[i],buffer);
  }
  return i;
}

/* Second function. This prints out information for individual *
 * exposures. Because of this, most of the parameters passed   *
 * to it are not arrays. This means that what is passed is     *
 * actually a copy of the argument in question. The function   *
 * is free to change this without affecting the value of the   *
 * variable back in main. The only exception is the string     *
 * held in the variable 'place'. 'place' is a pointer and is   *
 * copied; the string it points to is not. Changes made to the *
 * contents of the string therefore affect the string in       *
 * main().                                                     */

int printexposure(char *place, int ap1, int ap2, int exposure, int i)
{ printf("Exposure %d was taken at %s\n",i,place);
  if (exposure > 0)
  { printf("with an exposure of %d ",exposure); } else
  { printf("with an exposure of 1/%d ",-exposure); }
  printf("and an aperture of %d.%d.\n\n",ap1,ap2);

  return 1;               /* Not necessary, but good practice. */
}

/* Main program. */
main()
{ int i,max_frames;
  int exposure[40], aperture[40][2];
  char *place[40];

  printf("Please enter the number of frames on the film.\n");
  printf("(Up to forty.)\n");
  scanf("%d",&max_frames);
  if (max_frames > 40) max_frames = 40;
  if (max_frames <  1) max_frames = 1;

  readfilm(aperture, exposure, place, max_frames);

  for (i=0; i<max_frames; i++)
  { printexposure(place[i], aperture[i][0],
                  aperture[i][1], exposure[i],i);
  }
  return 0;
}
00000000  2f 2a 20 4b 61 74 65 20  34 3a 20 74 68 65 20 66  |/* Kate 4: the f|
00000010  6f 75 72 74 68 20 66 72  61 67 6d 65 6e 74 20 6f  |ourth fragment o|
00000020  66 20 74 68 65 20 67 72  61 6e 64 20 70 68 6f 74  |f the grand phot|
00000030  6f 2d 63 61 74 61 6c 6f  67 75 69 6e 67 20 70 72  |o-cataloguing pr|
00000040  6f 67 72 61 6d 2e 20 20  20 2a 0a 20 2a 20 49 6e  |ogram.   *. * In|
00000050  63 6c 75 64 65 20 68 65  61 64 65 72 20 66 69 6c  |clude header fil|
00000060  65 73 20 74 6f 20 64 65  66 69 6e 65 20 66 75 6e  |es to define fun|
00000070  63 74 69 6f 6e 73 20 66  6f 72 20 49 2f 4f 20 61  |ctions for I/O a|
00000080  6e 64 20 73 74 72 69 6e  67 20 68 61 6e 64 6c 69  |nd string handli|
00000090  6e 67 2e 20 2a 2f 0a 0a  23 69 6e 63 6c 75 64 65  |ng. */..#include|
000000a0  20 3c 73 74 64 69 6f 2e  68 3e 0a 23 69 6e 63 6c  | <stdio.h>.#incl|
000000b0  75 64 65 20 3c 73 74 72  69 6e 67 2e 68 3e 0a 23  |ude <string.h>.#|
000000c0  69 6e 63 6c 75 64 65 20  3c 73 74 64 6c 69 62 2e  |include <stdlib.|
000000d0  68 3e 0a 0a 2f 2a 20 46  69 72 73 74 20 66 75 6e  |h>../* First fun|
000000e0  63 74 69 6f 6e 2e 20 54  68 69 73 20 72 65 61 64  |ction. This read|
000000f0  73 20 69 6e 20 61 6c 6c  20 74 68 65 20 61 72 72  |s in all the arr|
00000100  61 79 73 20 69 6e 20 6f  6e 65 20 67 6f 2e 20 2a  |ays in one go. *|
00000110  0a 20 2a 20 54 68 65 20  61 72 72 61 79 20 72 65  |. * The array re|
00000120  74 75 72 6e 73 20 61 6e  20 69 6e 74 65 67 65 72  |turns an integer|
00000130  20 65 71 75 61 6c 20 74  6f 20 74 68 65 20 6e 75  | equal to the nu|
00000140  6d 62 65 72 20 6f 66 20  20 20 20 20 2a 0a 20 2a  |mber of     *. *|
00000150  20 66 72 61 6d 65 73 20  72 65 61 64 2c 20 74 6f  | frames read, to|
00000160  20 61 6c 6c 6f 77 20 66  6f 72 20 65 78 70 61 6e  | allow for expan|
00000170  73 69 6f 6e 20 74 6f 20  63 6f 70 65 20 77 69 74  |sion to cope wit|
00000180  68 20 74 68 65 20 20 20  20 2a 0a 20 2a 20 63 69  |h the    *. * ci|
00000190  72 63 75 6d 73 74 61 6e  63 65 20 77 68 65 6e 20  |rcumstance when |
000001a0  61 20 75 73 65 72 20 61  62 6f 72 74 73 20 74 68  |a user aborts th|
000001b0  65 20 72 65 61 64 20 68  61 6c 66 77 61 79 20 20  |e read halfway  |
000001c0  20 20 20 20 20 20 2a 0a  20 2a 20 74 68 72 6f 75  |      *. * throu|
000001d0  67 68 2e 20 54 68 65 20  61 72 72 61 79 73 20 61  |gh. The arrays a|
000001e0  72 65 20 70 61 73 73 65  64 20 74 6f 20 74 68 65  |re passed to the|
000001f0  20 66 75 6e 63 74 69 6f  6e 20 61 73 20 20 20 20  | function as    |
00000200  20 20 20 2a 0a 20 2a 20  70 6f 69 6e 74 65 72 73  |   *. * pointers|
00000210  20 72 61 74 68 65 72 20  74 68 61 6e 20 62 65 69  | rather than bei|
00000220  6e 67 20 63 6f 70 69 65  64 73 2e 20 41 6e 79 20  |ng copieds. Any |
00000230  63 68 61 6e 67 65 73 20  74 6f 20 74 68 65 20 20  |changes to the  |
00000240  2a 0a 20 2a 20 61 72 72  61 79 73 20 69 6e 20 74  |*. * arrays in t|
00000250  68 65 20 66 75 6e 63 74  69 6f 6e 20 77 69 6c 6c  |he function will|
00000260  20 74 68 65 72 65 66 6f  72 65 20 63 68 61 6e 67  | therefore chang|
00000270  65 20 74 68 65 20 61 72  72 61 79 73 20 2a 0a 20  |e the arrays *. |
00000280  2a 20 69 6e 20 6d 61 69  6e 28 29 2c 20 73 69 6e  |* in main(), sin|
00000290  63 65 20 74 68 65 79 20  6f 63 63 75 70 79 20 74  |ce they occupy t|
000002a0  68 65 20 73 61 6d 65 20  61 64 64 72 65 73 73 20  |he same address |
000002b0  73 70 61 63 65 2e 20 20  20 20 2a 0a 20 2a 20 54  |space.    *. * T|
000002c0  68 65 20 6e 75 6d 62 65  72 20 6f 66 20 65 78 70  |he number of exp|
000002d0  6f 73 75 72 65 73 20 6f  6e 20 74 68 65 20 66 69  |osures on the fi|
000002e0  6c 6d 20 69 73 20 70 61  73 73 65 64 20 61 73 20  |lm is passed as |
000002f0  61 6e 20 20 20 20 20 2a  0a 20 2a 20 69 6e 74 65  |an     *. * inte|
00000300  67 65 72 20 6e 2e 20 49  6e 20 74 68 69 73 20 63  |ger n. In this c|
00000310  61 73 65 20 69 74 20 69  73 20 61 20 63 6f 70 79  |ase it is a copy|
00000320  20 6f 66 20 6e 20 74 68  61 74 20 69 73 20 20 20  | of n that is   |
00000330  20 20 20 20 2a 0a 20 2a  20 70 61 73 73 65 64 2c  |    *. * passed,|
00000340  20 73 6f 20 61 6e 79 20  63 68 61 6e 67 65 73 20  | so any changes |
00000350  74 6f 20 6e 20 69 6e 20  72 65 61 64 66 69 6c 6d  |to n in readfilm|
00000360  28 29 20 77 69 6c 6c 20  6e 6f 74 20 20 20 20 20  |() will not     |
00000370  20 2a 0a 20 2a 20 61 66  66 65 63 74 20 74 68 65  | *. * affect the|
00000380  20 76 61 72 69 61 62 6c  65 20 69 6e 20 6d 61 69  | variable in mai|
00000390  6e 28 29 2e 20 20 20 20  20 20 20 20 20 20 20 20  |n().            |
000003a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 2a 2f  |              */|
000003b0  0a 0a 69 6e 74 20 72 65  61 64 66 69 6c 6d 28 69  |..int readfilm(i|
000003c0  6e 74 20 61 70 65 72 74  75 72 65 5b 34 30 5d 5b  |nt aperture[40][|
000003d0  32 5d 2c 20 69 6e 74 20  2a 65 78 70 6f 73 75 72  |2], int *exposur|
000003e0  65 2c 20 63 68 61 72 20  2a 70 6c 61 63 65 5b 34  |e, char *place[4|
000003f0  30 5d 2c 20 69 6e 74 20  6e 29 0a 7b 20 69 6e 74  |0], int n).{ int|
00000400  20 69 2c 20 6c 65 6e 3b  0a 20 20 66 6c 6f 61 74  | i, len;.  float|
00000410  20 64 61 74 75 6d 3b 0a  20 20 63 68 61 72 20 62  | datum;.  char b|
00000420  75 66 66 65 72 5b 32 35  36 5d 3b 0a 0a 20 20 70  |uffer[256];..  p|
00000430  72 69 6e 74 66 28 22 59  6f 75 20 77 69 6c 6c 20  |rintf("You will |
00000440  6e 6f 77 20 62 65 20 61  73 6b 65 64 20 74 6f 20  |now be asked to |
00000450  65 6e 74 65 72 20 65 78  70 6f 73 75 72 65 2c 20  |enter exposure, |
00000460  61 70 65 72 74 75 72 65  20 61 6e 64 5c 6e 22 29  |aperture and\n")|
00000470  3b 0a 20 20 70 72 69 6e  74 66 28 22 6c 6f 63 61  |;.  printf("loca|
00000480  74 69 6f 6e 20 64 61 74  61 20 66 6f 72 20 65 61  |tion data for ea|
00000490  63 68 20 66 72 61 6d 65  20 6f 6e 20 74 68 65 20  |ch frame on the |
000004a0  66 69 6c 6d 2e 5c 6e 22  29 3b 0a 20 20 70 72 69  |film.\n");.  pri|
000004b0  6e 74 66 28 22 49 66 20  74 68 65 20 65 78 70 6f  |ntf("If the expo|
000004c0  73 75 72 65 20 69 73 20  6c 65 73 73 20 74 68 61  |sure is less tha|
000004d0  6e 20 6f 6e 65 20 73 65  63 6f 6e 64 2c 20 69 74  |n one second, it|
000004e0  20 73 68 6f 75 6c 64 20  62 65 5c 6e 22 29 3b 0a  | should be\n");.|
000004f0  20 20 70 72 69 6e 74 66  28 22 65 6e 74 65 72 65  |  printf("entere|
00000500  64 20 61 73 20 6d 69 6e  75 73 20 74 68 65 20 72  |d as minus the r|
00000510  65 63 69 70 72 6f 63 61  6c 20 6f 66 20 74 68 65  |eciprocal of the|
00000520  20 65 78 70 6f 73 75 72  65 2e 20 46 6f 72 5c 6e  | exposure. For\n|
00000530  22 29 3b 0a 20 20 70 72  69 6e 74 66 28 22 69 6e  |");.  printf("in|
00000540  73 74 61 6e 63 65 2c 20  61 6e 20 65 78 70 6f 73  |stance, an expos|
00000550  75 72 65 20 6f 66 20 61  20 74 68 69 72 74 69 65  |ure of a thirtie|
00000560  74 68 20 6f 66 20 61 20  73 65 63 6f 6e 64 20 73  |th of a second s|
00000570  68 6f 75 6c 64 5c 6e 22  29 3b 0a 20 20 70 72 69  |hould\n");.  pri|
00000580  6e 74 66 28 22 62 65 20  65 6e 74 65 72 65 64 20  |ntf("be entered |
00000590  61 73 20 5c 22 2d 33 30  5c 22 2e 5c 6e 22 29 3b  |as \"-30\".\n");|
000005a0  0a 20 20 70 72 69 6e 74  66 28 22 41 6c 6c 20 6c  |.  printf("All l|
000005b0  6f 63 61 74 69 6f 6e 73  20 73 68 6f 75 6c 64 20  |ocations should |
000005c0  62 65 20 73 68 6f 72 74  65 72 20 74 68 61 6e 20  |be shorter than |
000005d0  32 35 35 20 63 68 61 72  61 63 74 65 72 73 20 6c  |255 characters l|
000005e0  6f 6e 67 2e 5c 6e 22 29  3b 0a 0a 20 20 66 6f 72  |ong.\n");..  for|
000005f0  20 28 69 3d 30 3b 20 69  3c 6e 3b 20 69 2b 2b 29  | (i=0; i<n; i++)|
00000600  0a 20 20 7b 20 70 72 69  6e 74 66 28 22 50 6c 65  |.  { printf("Ple|
00000610  61 73 65 20 65 6e 74 65  72 20 74 68 65 20 65 78  |ase enter the ex|
00000620  70 6f 73 75 72 65 20 6f  66 20 66 72 61 6d 65 20  |posure of frame |
00000630  25 64 2e 5c 6e 22 2c 69  29 3b 0a 20 20 20 20 73  |%d.\n",i);.    s|
00000640  63 61 6e 66 28 22 25 64  22 2c 26 65 78 70 6f 73  |canf("%d",&expos|
00000650  75 72 65 5b 69 5d 29 3b  0a 20 20 20 20 70 72 69  |ure[i]);.    pri|
00000660  6e 74 66 28 22 50 6c 65  61 73 65 20 65 6e 74 65  |ntf("Please ente|
00000670  72 20 74 68 65 20 61 70  65 72 74 75 72 65 20 73  |r the aperture s|
00000680  65 74 74 69 6e 67 20 66  6f 72 20 66 72 61 6d 65  |etting for frame|
00000690  20 25 64 2e 5c 6e 22 2c  69 29 3b 0a 20 20 20 20  | %d.\n",i);.    |
000006a0  73 63 61 6e 66 28 22 25  66 22 2c 26 64 61 74 75  |scanf("%f",&datu|
000006b0  6d 29 3b 0a 20 20 20 20  61 70 65 72 74 75 72 65  |m);.    aperture|
000006c0  5b 69 5d 5b 30 5d 20 3d  20 28 69 6e 74 29 64 61  |[i][0] = (int)da|
000006d0  74 75 6d 3b 0a 20 20 20  20 61 70 65 72 74 75 72  |tum;.    apertur|
000006e0  65 5b 69 5d 5b 31 5d 20  3d 20 28 64 61 74 75 6d  |e[i][1] = (datum|
000006f0  20 2d 20 61 70 65 72 74  75 72 65 5b 69 5d 5b 30  | - aperture[i][0|
00000700  5d 29 20 2a 20 31 30 3b  0a 20 20 20 20 70 72 69  |]) * 10;.    pri|
00000710  6e 74 66 28 22 50 6c 65  61 73 65 20 65 6e 74 65  |ntf("Please ente|
00000720  72 20 74 68 65 20 6c 6f  63 74 69 6f 6e 20 66 6f  |r the loction fo|
00000730  72 20 66 72 61 6d 65 20  25 64 2e 5c 6e 22 2c 69  |r frame %d.\n",i|
00000740  29 3b 0a 20 20 20 20 67  65 74 63 68 61 72 28 29  |);.    getchar()|
00000750  3b 0a 20 20 20 20 67 65  74 73 28 62 75 66 66 65  |;.    gets(buffe|
00000760  72 29 3b 0a 20 20 20 20  6c 65 6e 20 3d 20 73 74  |r);.    len = st|
00000770  72 6c 65 6e 28 62 75 66  66 65 72 29 3b 0a 20 20  |rlen(buffer);.  |
00000780  20 20 70 6c 61 63 65 5b  69 5d 20 3d 20 6d 61 6c  |  place[i] = mal|
00000790  6c 6f 63 28 6c 65 6e 2b  31 29 3b 0a 20 20 20 20  |loc(len+1);.    |
000007a0  73 74 72 63 70 79 28 70  6c 61 63 65 5b 69 5d 2c  |strcpy(place[i],|
000007b0  62 75 66 66 65 72 29 3b  0a 20 20 7d 0a 20 20 72  |buffer);.  }.  r|
000007c0  65 74 75 72 6e 20 69 3b  0a 7d 0a 0a 2f 2a 20 53  |eturn i;.}../* S|
000007d0  65 63 6f 6e 64 20 66 75  6e 63 74 69 6f 6e 2e 20  |econd function. |
000007e0  54 68 69 73 20 70 72 69  6e 74 73 20 6f 75 74 20  |This prints out |
000007f0  69 6e 66 6f 72 6d 61 74  69 6f 6e 20 66 6f 72 20  |information for |
00000800  69 6e 64 69 76 69 64 75  61 6c 20 2a 0a 20 2a 20  |individual *. * |
00000810  65 78 70 6f 73 75 72 65  73 2e 20 42 65 63 61 75  |exposures. Becau|
00000820  73 65 20 6f 66 20 74 68  69 73 2c 20 6d 6f 73 74  |se of this, most|
00000830  20 6f 66 20 74 68 65 20  70 61 72 61 6d 65 74 65  | of the paramete|
00000840  72 73 20 70 61 73 73 65  64 20 20 20 2a 0a 20 2a  |rs passed   *. *|
00000850  20 74 6f 20 69 74 20 61  72 65 20 6e 6f 74 20 61  | to it are not a|
00000860  72 72 61 79 73 2e 20 54  68 69 73 20 6d 65 61 6e  |rrays. This mean|
00000870  73 20 74 68 61 74 20 77  68 61 74 20 69 73 20 70  |s that what is p|
00000880  61 73 73 65 64 20 69 73  20 20 20 20 20 2a 0a 20  |assed is     *. |
00000890  2a 20 61 63 74 75 61 6c  6c 79 20 61 20 63 6f 70  |* actually a cop|
000008a0  79 20 6f 66 20 74 68 65  20 61 72 67 75 6d 65 6e  |y of the argumen|
000008b0  74 20 69 6e 20 71 75 65  73 74 69 6f 6e 2e 20 54  |t in question. T|
000008c0  68 65 20 66 75 6e 63 74  69 6f 6e 20 20 20 2a 0a  |he function   *.|
000008d0  20 2a 20 69 73 20 66 72  65 65 20 74 6f 20 63 68  | * is free to ch|
000008e0  61 6e 67 65 20 74 68 69  73 20 77 69 74 68 6f 75  |ange this withou|
000008f0  74 20 61 66 66 65 63 74  69 6e 67 20 74 68 65 20  |t affecting the |
00000900  76 61 6c 75 65 20 6f 66  20 74 68 65 20 20 20 2a  |value of the   *|
00000910  0a 20 2a 20 76 61 72 69  61 62 6c 65 20 62 61 63  |. * variable bac|
00000920  6b 20 69 6e 20 6d 61 69  6e 2e 20 54 68 65 20 6f  |k in main. The o|
00000930  6e 6c 79 20 65 78 63 65  70 74 69 6f 6e 20 69 73  |nly exception is|
00000940  20 74 68 65 20 73 74 72  69 6e 67 20 20 20 20 20  | the string     |
00000950  2a 0a 20 2a 20 68 65 6c  64 20 69 6e 20 74 68 65  |*. * held in the|
00000960  20 76 61 72 69 61 62 6c  65 20 27 70 6c 61 63 65  | variable 'place|
00000970  27 2e 20 27 70 6c 61 63  65 27 20 69 73 20 61 20  |'. 'place' is a |
00000980  70 6f 69 6e 74 65 72 20  61 6e 64 20 69 73 20 20  |pointer and is  |
00000990  20 2a 0a 20 2a 20 63 6f  70 69 65 64 3b 20 74 68  | *. * copied; th|
000009a0  65 20 73 74 72 69 6e 67  20 69 74 20 70 6f 69 6e  |e string it poin|
000009b0  74 73 20 74 6f 20 69 73  20 6e 6f 74 2e 20 43 68  |ts to is not. Ch|
000009c0  61 6e 67 65 73 20 6d 61  64 65 20 74 6f 20 74 68  |anges made to th|
000009d0  65 20 2a 0a 20 2a 20 63  6f 6e 74 65 6e 74 73 20  |e *. * contents |
000009e0  6f 66 20 74 68 65 20 73  74 72 69 6e 67 20 74 68  |of the string th|
000009f0  65 72 65 66 6f 72 65 20  61 66 66 65 63 74 20 74  |erefore affect t|
00000a00  68 65 20 73 74 72 69 6e  67 20 69 6e 20 20 20 20  |he string in    |
00000a10  20 20 20 2a 0a 20 2a 20  6d 61 69 6e 28 29 2e 20  |   *. * main(). |
00000a20  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000a50  20 20 20 20 2a 2f 0a 0a  69 6e 74 20 70 72 69 6e  |    */..int prin|
00000a60  74 65 78 70 6f 73 75 72  65 28 63 68 61 72 20 2a  |texposure(char *|
00000a70  70 6c 61 63 65 2c 20 69  6e 74 20 61 70 31 2c 20  |place, int ap1, |
00000a80  69 6e 74 20 61 70 32 2c  20 69 6e 74 20 65 78 70  |int ap2, int exp|
00000a90  6f 73 75 72 65 2c 20 69  6e 74 20 69 29 0a 7b 20  |osure, int i).{ |
00000aa0  70 72 69 6e 74 66 28 22  45 78 70 6f 73 75 72 65  |printf("Exposure|
00000ab0  20 25 64 20 77 61 73 20  74 61 6b 65 6e 20 61 74  | %d was taken at|
00000ac0  20 25 73 5c 6e 22 2c 69  2c 70 6c 61 63 65 29 3b  | %s\n",i,place);|
00000ad0  0a 20 20 69 66 20 28 65  78 70 6f 73 75 72 65 20  |.  if (exposure |
00000ae0  3e 20 30 29 0a 20 20 7b  20 70 72 69 6e 74 66 28  |> 0).  { printf(|
00000af0  22 77 69 74 68 20 61 6e  20 65 78 70 6f 73 75 72  |"with an exposur|
00000b00  65 20 6f 66 20 25 64 20  22 2c 65 78 70 6f 73 75  |e of %d ",exposu|
00000b10  72 65 29 3b 20 7d 20 65  6c 73 65 0a 20 20 7b 20  |re); } else.  { |
00000b20  70 72 69 6e 74 66 28 22  77 69 74 68 20 61 6e 20  |printf("with an |
00000b30  65 78 70 6f 73 75 72 65  20 6f 66 20 31 2f 25 64  |exposure of 1/%d|
00000b40  20 22 2c 2d 65 78 70 6f  73 75 72 65 29 3b 20 7d  | ",-exposure); }|
00000b50  0a 20 20 70 72 69 6e 74  66 28 22 61 6e 64 20 61  |.  printf("and a|
00000b60  6e 20 61 70 65 72 74 75  72 65 20 6f 66 20 25 64  |n aperture of %d|
00000b70  2e 25 64 2e 5c 6e 5c 6e  22 2c 61 70 31 2c 61 70  |.%d.\n\n",ap1,ap|
00000b80  32 29 3b 0a 0a 20 20 72  65 74 75 72 6e 20 31 3b  |2);..  return 1;|
00000b90  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 2f  |               /|
00000ba0  2a 20 4e 6f 74 20 6e 65  63 65 73 73 61 72 79 2c  |* Not necessary,|
00000bb0  20 62 75 74 20 67 6f 6f  64 20 70 72 61 63 74 69  | but good practi|
00000bc0  63 65 2e 20 2a 2f 0a 7d  0a 0a 2f 2a 20 4d 61 69  |ce. */.}../* Mai|
00000bd0  6e 20 70 72 6f 67 72 61  6d 2e 20 2a 2f 0a 6d 61  |n program. */.ma|
00000be0  69 6e 28 29 0a 7b 20 69  6e 74 20 69 2c 6d 61 78  |in().{ int i,max|
00000bf0  5f 66 72 61 6d 65 73 3b  0a 20 20 69 6e 74 20 65  |_frames;.  int e|
00000c00  78 70 6f 73 75 72 65 5b  34 30 5d 2c 20 61 70 65  |xposure[40], ape|
00000c10  72 74 75 72 65 5b 34 30  5d 5b 32 5d 3b 0a 20 20  |rture[40][2];.  |
00000c20  63 68 61 72 20 2a 70 6c  61 63 65 5b 34 30 5d 3b  |char *place[40];|
00000c30  0a 0a 20 20 70 72 69 6e  74 66 28 22 50 6c 65 61  |..  printf("Plea|
00000c40  73 65 20 65 6e 74 65 72  20 74 68 65 20 6e 75 6d  |se enter the num|
00000c50  62 65 72 20 6f 66 20 66  72 61 6d 65 73 20 6f 6e  |ber of frames on|
00000c60  20 74 68 65 20 66 69 6c  6d 2e 5c 6e 22 29 3b 0a  | the film.\n");.|
00000c70  20 20 70 72 69 6e 74 66  28 22 28 55 70 20 74 6f  |  printf("(Up to|
00000c80  20 66 6f 72 74 79 2e 29  5c 6e 22 29 3b 0a 20 20  | forty.)\n");.  |
00000c90  73 63 61 6e 66 28 22 25  64 22 2c 26 6d 61 78 5f  |scanf("%d",&max_|
00000ca0  66 72 61 6d 65 73 29 3b  0a 20 20 69 66 20 28 6d  |frames);.  if (m|
00000cb0  61 78 5f 66 72 61 6d 65  73 20 3e 20 34 30 29 20  |ax_frames > 40) |
00000cc0  6d 61 78 5f 66 72 61 6d  65 73 20 3d 20 34 30 3b  |max_frames = 40;|
00000cd0  0a 20 20 69 66 20 28 6d  61 78 5f 66 72 61 6d 65  |.  if (max_frame|
00000ce0  73 20 3c 20 20 31 29 20  6d 61 78 5f 66 72 61 6d  |s <  1) max_fram|
00000cf0  65 73 20 3d 20 31 3b 0a  0a 20 20 72 65 61 64 66  |es = 1;..  readf|
00000d00  69 6c 6d 28 61 70 65 72  74 75 72 65 2c 20 65 78  |ilm(aperture, ex|
00000d10  70 6f 73 75 72 65 2c 20  70 6c 61 63 65 2c 20 6d  |posure, place, m|
00000d20  61 78 5f 66 72 61 6d 65  73 29 3b 0a 0a 20 20 66  |ax_frames);..  f|
00000d30  6f 72 20 28 69 3d 30 3b  20 69 3c 6d 61 78 5f 66  |or (i=0; i<max_f|
00000d40  72 61 6d 65 73 3b 20 69  2b 2b 29 0a 20 20 7b 20  |rames; i++).  { |
00000d50  70 72 69 6e 74 65 78 70  6f 73 75 72 65 28 70 6c  |printexposure(pl|
00000d60  61 63 65 5b 69 5d 2c 20  61 70 65 72 74 75 72 65  |ace[i], aperture|
00000d70  5b 69 5d 5b 30 5d 2c 0a  20 20 20 20 20 20 20 20  |[i][0],.        |
00000d80  20 20 20 20 20 20 20 20  20 20 61 70 65 72 74 75  |          apertu|
00000d90  72 65 5b 69 5d 5b 31 5d  2c 20 65 78 70 6f 73 75  |re[i][1], exposu|
00000da0  72 65 5b 69 5d 2c 69 29  3b 0a 20 20 7d 0a 20 20  |re[i],i);.  }.  |
00000db0  72 65 74 75 72 6e 20 30  3b 0a 7d 0a              |return 0;.}.|
00000dbc