Home » Archimedes archive » Acorn User » AU 1995-01.adf » !C_C » c/Kate3
c/Kate3
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-01.adf » !C_C |
Filename: | c/Kate3 |
Read OK: | ✔ |
File size: | 1393 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
/* Kate 2: the second 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> /* Main program. */ main() { int *exposure; /* Initialise everything using pointers */ int **aperture; char **place; /* Since the original place was an array of */ /* pointers the object pointed to by place is */ /* itself a pointer. This is the reason for the */ /* double asterisk. aperture has one for a */ /* the same reason. */ int i,max_frames,len; float datum; char *buffer; /* Buffer is where the text for the location of */ /* each photograph is placed, while the length of */ /* the text is assessed. */ buffer = malloc(256); printf("Please enter the number of frames on the film.\n"); printf("(Up to forty.)\n"); /* The scanf() function reads values in from the keyboard. The first */ /* function argument is a formatting string; the second */ /* argument gives the _address_ of the datum to be read in (hence */ /* it is prefixed by an ampersand). The maximum number of frames is */ /* checked to make sure that it is positive, and then the blocks of */ /* memory are initialised to the appropriate size. */ scanf("%d",&max_frames); if (max_frames < 1) max_frames = 1; exposure = malloc(max_frames*sizeof(int)); aperture = malloc(max_frames*sizeof(int*)); place = malloc(max_frames*sizeof(char*)); 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"); /* The program now goes through a loop. The loop starts from zero. This */ /* is deliberate, and is because most films actually start from frame */ /* zero, unless you get over-enthusiastic while loading the film. */ for (i=0; i<max_frames; 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); /* The aperture is read as a floating point number, and the integer and */ /* the first decimal place parts of the number are held in elements zero */ /* and one of the array. The double asterisk looks daunting, but works, */ /* since aperture is technically a pointer to a pointer. */ *(aperture + i) = malloc(2*sizeof(int)); scanf("%f",&datum); **(aperture + i) = (int)datum; *(*(aperture+i)+1) = (datum - **(aperture+i)) * 10; printf("Please enter the loction for frame %d.\n",i); getchar(); /* The gets() function reads a line of text from the keyboard into a */ /* string. It takes as an argument a pointer to the string. */ gets(buffer); /* strlen() returns the length of a string. It does _not_ include the */ /* terminating zero byte. */ len = strlen(buffer); /* Set up the pointer in place[i] to point to an area big enough to hold */ /* the string just input. Note: 1) sizeof(char) is assumed to be one, so */ /* not needed in the malloc() statement and 2) the block must be one */ /* byte longer than the number of characters in the string to allow for */ /* the terminating zero. */ *(place+i) = malloc(len+1); /* strcpy() copies one string to another string - which cannot be done */ /* in C by a simple string1=string2 command. In this case, the string */ /* pointed to by the pointer 'buffer' is copied to the memory block */ /* pointed to by the pointer '*(place+i)'. The copying stops when a */ /* terminating zero is enountered in the string pointed to by buffer. */ strcpy(*(place+i),buffer); } /* The next loop prints out all the values that we have just input. */ for (i=0; i<max_frames; i++) { printf("Exposure %d was taken at %s\n",i,*(place+i)); if (*(exposure+i) > 0) { printf("with an exposure of %d ",*(exposure+i)); } else { printf("with an exposure of 1/%d ",-*(exposure+i)); } printf("and an aperture of %d.%d.\n\n",**(aperture+i), *(*(aperture+i)+1)); } /* Since main() is technically a function, we should return zero from */ /* it to reassure the machine that everything has gone well. Don't */ /* worry about this for the moment. */ return 0; }
00000000 2f 2a 20 4b 61 74 65 20 32 3a 20 74 68 65 20 73 |/* Kate 2: the s| 00000010 65 63 6f 6e 64 20 66 72 61 67 6d 65 6e 74 20 6f |econd 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 2f 0a 0a 2f 2a 20 |ogram. */../* | 00000050 49 6e 63 6c 75 64 65 20 68 65 61 64 65 72 20 66 |Include header f| 00000060 69 6c 65 73 20 74 6f 20 64 65 66 69 6e 65 20 66 |iles to define f| 00000070 75 6e 63 74 69 6f 6e 73 20 66 6f 72 20 49 2f 4f |unctions for I/O| 00000080 20 61 6e 64 20 73 74 72 69 6e 67 20 68 61 6e 64 | and string hand| 00000090 6c 69 6e 67 2e 20 2a 2f 0a 23 69 6e 63 6c 75 64 |ling. */.#includ| 000000a0 65 20 3c 73 74 64 69 6f 2e 68 3e 0a 23 69 6e 63 |e <stdio.h>.#inc| 000000b0 6c 75 64 65 20 3c 73 74 72 69 6e 67 2e 68 3e 0a |lude <string.h>.| 000000c0 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 6c 69 62 |#include <stdlib| 000000d0 2e 68 3e 0a 0a 2f 2a 20 4d 61 69 6e 20 70 72 6f |.h>../* Main pro| 000000e0 67 72 61 6d 2e 20 2a 2f 0a 6d 61 69 6e 28 29 0a |gram. */.main().| 000000f0 7b 20 69 6e 74 20 2a 65 78 70 6f 73 75 72 65 3b |{ int *exposure;| 00000100 20 20 20 20 20 20 20 2f 2a 20 49 6e 69 74 69 61 | /* Initia| 00000110 6c 69 73 65 20 65 76 65 72 79 74 68 69 6e 67 20 |lise everything | 00000120 75 73 69 6e 67 20 70 6f 69 6e 74 65 72 73 20 20 |using pointers | 00000130 20 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 69 6e | */. in| 00000140 74 20 2a 2a 61 70 65 72 74 75 72 65 3b 0a 20 20 |t **aperture;. | 00000150 63 68 61 72 20 2a 2a 70 6c 61 63 65 3b 20 20 20 |char **place; | 00000160 20 20 20 20 20 2f 2a 20 53 69 6e 63 65 20 74 68 | /* Since th| 00000170 65 20 6f 72 69 67 69 6e 61 6c 20 70 6c 61 63 65 |e original place| 00000180 20 77 61 73 20 61 6e 20 61 72 72 61 79 20 6f 66 | was an array of| 00000190 20 20 20 20 20 20 20 2a 2f 0a 20 20 20 20 20 20 | */. | 000001a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000001b0 20 2f 2a 20 70 6f 69 6e 74 65 72 73 20 74 68 65 | /* pointers the| 000001c0 20 6f 62 6a 65 63 74 20 70 6f 69 6e 74 65 64 20 | object pointed | 000001d0 74 6f 20 62 79 20 70 6c 61 63 65 20 69 73 20 20 |to by place is | 000001e0 20 20 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 | */. | 000001f0 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 | /* | 00000200 69 74 73 65 6c 66 20 61 20 70 6f 69 6e 74 65 72 |itself a pointer| 00000210 2e 20 54 68 69 73 20 69 73 20 74 68 65 20 72 65 |. This is the re| 00000220 61 73 6f 6e 20 66 6f 72 20 74 68 65 20 20 20 2a |ason for the *| 00000230 2f 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |/. | 00000240 20 20 20 20 20 20 20 20 20 2f 2a 20 64 6f 75 62 | /* doub| 00000250 6c 65 20 61 73 74 65 72 69 73 6b 2e 20 61 70 65 |le asterisk. ape| 00000260 72 74 75 72 65 20 68 61 73 20 6f 6e 65 20 66 6f |rture has one fo| 00000270 72 20 61 20 20 20 20 20 20 20 20 2a 2f 0a 20 20 |r a */. | 00000280 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000290 20 20 20 20 20 2f 2a 20 74 68 65 20 73 61 6d 65 | /* the same| 000002a0 20 72 65 61 73 6f 6e 2e 20 20 20 20 20 20 20 20 | reason. | 000002b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000002c0 20 20 20 20 20 20 20 2a 2f 0a 20 20 69 6e 74 20 | */. int | 000002d0 69 2c 6d 61 78 5f 66 72 61 6d 65 73 2c 6c 65 6e |i,max_frames,len| 000002e0 3b 0a 20 20 66 6c 6f 61 74 20 64 61 74 75 6d 3b |;. float datum;| 000002f0 0a 20 20 63 68 61 72 20 2a 62 75 66 66 65 72 3b |. char *buffer;| 00000300 20 20 20 20 20 20 20 20 2f 2a 20 42 75 66 66 65 | /* Buffe| 00000310 72 20 69 73 20 77 68 65 72 65 20 74 68 65 20 74 |r is where the t| 00000320 65 78 74 20 66 6f 72 20 74 68 65 20 6c 6f 63 61 |ext for the loca| 00000330 74 69 6f 6e 20 6f 66 20 20 20 2a 2f 0a 20 20 20 |tion of */. | 00000340 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000350 20 20 20 20 2f 2a 20 65 61 63 68 20 70 68 6f 74 | /* each phot| 00000360 6f 67 72 61 70 68 20 69 73 20 70 6c 61 63 65 64 |ograph is placed| 00000370 2c 20 77 68 69 6c 65 20 74 68 65 20 6c 65 6e 67 |, while the leng| 00000380 74 68 20 6f 66 20 2a 2f 0a 20 20 20 20 20 20 20 |th of */. | 00000390 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000003a0 2f 2a 20 74 68 65 20 74 65 78 74 20 69 73 20 61 |/* the text is a| 000003b0 73 73 65 73 73 65 64 2e 20 20 20 20 20 20 20 20 |ssessed. | 000003c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000003d0 20 20 2a 2f 0a 0a 20 20 62 75 66 66 65 72 20 3d | */.. buffer =| 000003e0 20 6d 61 6c 6c 6f 63 28 32 35 36 29 3b 0a 0a 20 | malloc(256);.. | 000003f0 20 70 72 69 6e 74 66 28 22 50 6c 65 61 73 65 20 | printf("Please | 00000400 65 6e 74 65 72 20 74 68 65 20 6e 75 6d 62 65 72 |enter the number| 00000410 20 6f 66 20 66 72 61 6d 65 73 20 6f 6e 20 74 68 | of frames on th| 00000420 65 20 66 69 6c 6d 2e 5c 6e 22 29 3b 0a 20 20 70 |e film.\n");. p| 00000430 72 69 6e 74 66 28 22 28 55 70 20 74 6f 20 66 6f |rintf("(Up to fo| 00000440 72 74 79 2e 29 5c 6e 22 29 3b 0a 0a 2f 2a 20 54 |rty.)\n");../* T| 00000450 68 65 20 73 63 61 6e 66 28 29 20 66 75 6e 63 74 |he scanf() funct| 00000460 69 6f 6e 20 72 65 61 64 73 20 76 61 6c 75 65 73 |ion reads values| 00000470 20 69 6e 20 66 72 6f 6d 20 74 68 65 20 6b 65 79 | in from the key| 00000480 62 6f 61 72 64 2e 20 54 68 65 20 66 69 72 73 74 |board. The first| 00000490 20 20 20 20 20 2a 2f 0a 2f 2a 20 66 75 6e 63 74 | */./* funct| 000004a0 69 6f 6e 20 61 72 67 75 6d 65 6e 74 20 69 73 20 |ion argument is | 000004b0 61 20 66 6f 72 6d 61 74 74 69 6e 67 20 73 74 72 |a formatting str| 000004c0 69 6e 67 3b 20 74 68 65 20 73 65 63 6f 6e 64 20 |ing; the second | 000004d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000004e0 20 2a 2f 0a 2f 2a 20 61 72 67 75 6d 65 6e 74 20 | */./* argument | 000004f0 67 69 76 65 73 20 74 68 65 20 5f 61 64 64 72 65 |gives the _addre| 00000500 73 73 5f 20 6f 66 20 74 68 65 20 64 61 74 75 6d |ss_ of the datum| 00000510 20 74 6f 20 62 65 20 72 65 61 64 20 69 6e 20 28 | to be read in (| 00000520 68 65 6e 63 65 20 20 20 20 20 20 20 20 2a 2f 0a |hence */.| 00000530 2f 2a 20 69 74 20 69 73 20 70 72 65 66 69 78 65 |/* it is prefixe| 00000540 64 20 62 79 20 61 6e 20 61 6d 70 65 72 73 61 6e |d by an ampersan| 00000550 64 29 2e 20 54 68 65 20 6d 61 78 69 6d 75 6d 20 |d). The maximum | 00000560 6e 75 6d 62 65 72 20 6f 66 20 66 72 61 6d 65 73 |number of frames| 00000570 20 69 73 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 63 | is */./* c| 00000580 68 65 63 6b 65 64 20 74 6f 20 6d 61 6b 65 20 73 |hecked to make s| 00000590 75 72 65 20 74 68 61 74 20 69 74 20 69 73 20 70 |ure that it is p| 000005a0 6f 73 69 74 69 76 65 2c 20 61 6e 64 20 74 68 65 |ositive, and the| 000005b0 6e 20 74 68 65 20 20 62 6c 6f 63 6b 73 20 6f 66 |n the blocks of| 000005c0 20 20 20 20 20 2a 2f 0a 2f 2a 20 6d 65 6d 6f 72 | */./* memor| 000005d0 79 20 61 72 65 20 69 6e 69 74 69 61 6c 69 73 65 |y are initialise| 000005e0 64 20 74 6f 20 74 68 65 20 61 70 70 72 6f 70 72 |d to the appropr| 000005f0 69 61 74 65 20 73 69 7a 65 2e 20 20 20 20 20 20 |iate size. | 00000600 20 20 20 20 20 20 20 2a 2f 0a 0a 20 20 73 63 61 | */.. sca| 00000610 6e 66 28 22 25 64 22 2c 26 6d 61 78 5f 66 72 61 |nf("%d",&max_fra| 00000620 6d 65 73 29 3b 0a 20 20 69 66 20 28 6d 61 78 5f |mes);. if (max_| 00000630 66 72 61 6d 65 73 20 3c 20 31 29 20 6d 61 78 5f |frames < 1) max_| 00000640 66 72 61 6d 65 73 20 3d 20 31 3b 0a 20 20 65 78 |frames = 1;. ex| 00000650 70 6f 73 75 72 65 20 3d 20 6d 61 6c 6c 6f 63 28 |posure = malloc(| 00000660 6d 61 78 5f 66 72 61 6d 65 73 2a 73 69 7a 65 6f |max_frames*sizeo| 00000670 66 28 69 6e 74 29 29 3b 0a 20 20 61 70 65 72 74 |f(int));. apert| 00000680 75 72 65 20 3d 20 6d 61 6c 6c 6f 63 28 6d 61 78 |ure = malloc(max| 00000690 5f 66 72 61 6d 65 73 2a 73 69 7a 65 6f 66 28 69 |_frames*sizeof(i| 000006a0 6e 74 2a 29 29 3b 0a 20 20 70 6c 61 63 65 20 20 |nt*));. place | 000006b0 20 20 3d 20 6d 61 6c 6c 6f 63 28 6d 61 78 5f 66 | = malloc(max_f| 000006c0 72 61 6d 65 73 2a 73 69 7a 65 6f 66 28 63 68 61 |rames*sizeof(cha| 000006d0 72 2a 29 29 3b 0a 0a 20 20 70 72 69 6e 74 66 28 |r*));.. printf(| 000006e0 22 59 6f 75 20 77 69 6c 6c 20 6e 6f 77 20 62 65 |"You will now be| 000006f0 20 61 73 6b 65 64 20 74 6f 20 65 6e 74 65 72 20 | asked to enter | 00000700 65 78 70 6f 73 75 72 65 2c 20 61 70 65 72 74 75 |exposure, apertu| 00000710 72 65 20 61 6e 64 5c 6e 22 29 3b 0a 20 20 70 72 |re and\n");. pr| 00000720 69 6e 74 66 28 22 6c 6f 63 61 74 69 6f 6e 20 64 |intf("location d| 00000730 61 74 61 20 66 6f 72 20 65 61 63 68 20 66 72 61 |ata for each fra| 00000740 6d 65 20 6f 6e 20 74 68 65 20 66 69 6c 6d 2e 5c |me on the film.\| 00000750 6e 22 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 49 |n");. printf("I| 00000760 66 20 74 68 65 20 65 78 70 6f 73 75 72 65 20 69 |f the exposure i| 00000770 73 20 6c 65 73 73 20 74 68 61 6e 20 6f 6e 65 20 |s less than one | 00000780 73 65 63 6f 6e 64 2c 20 69 74 20 73 68 6f 75 6c |second, it shoul| 00000790 64 20 62 65 5c 6e 22 29 3b 0a 20 20 70 72 69 6e |d be\n");. prin| 000007a0 74 66 28 22 65 6e 74 65 72 65 64 20 61 73 20 6d |tf("entered as m| 000007b0 69 6e 75 73 20 74 68 65 20 72 65 63 69 70 72 6f |inus the recipro| 000007c0 63 61 6c 20 6f 66 20 74 68 65 20 65 78 70 6f 73 |cal of the expos| 000007d0 75 72 65 2e 20 46 6f 72 5c 6e 22 29 3b 0a 20 20 |ure. For\n");. | 000007e0 70 72 69 6e 74 66 28 22 69 6e 73 74 61 6e 63 65 |printf("instance| 000007f0 2c 20 61 6e 20 65 78 70 6f 73 75 72 65 20 6f 66 |, an exposure of| 00000800 20 61 20 74 68 69 72 74 69 65 74 68 20 6f 66 20 | a thirtieth of | 00000810 61 20 73 65 63 6f 6e 64 20 73 68 6f 75 6c 64 5c |a second should\| 00000820 6e 22 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 62 |n");. printf("b| 00000830 65 20 65 6e 74 65 72 65 64 20 61 73 20 5c 22 2d |e entered as \"-| 00000840 33 30 5c 22 2e 5c 6e 22 29 3b 0a 20 20 70 72 69 |30\".\n");. pri| 00000850 6e 74 66 28 22 41 6c 6c 20 6c 6f 63 61 74 69 6f |ntf("All locatio| 00000860 6e 73 20 73 68 6f 75 6c 64 20 62 65 20 73 68 6f |ns should be sho| 00000870 72 74 65 72 20 74 68 61 6e 20 32 35 35 20 63 68 |rter than 255 ch| 00000880 61 72 61 63 74 65 72 73 20 6c 6f 6e 67 2e 5c 6e |aracters long.\n| 00000890 22 29 3b 0a 0a 2f 2a 20 54 68 65 20 70 72 6f 67 |");../* The prog| 000008a0 72 61 6d 20 6e 6f 77 20 67 6f 65 73 20 74 68 72 |ram now goes thr| 000008b0 6f 75 67 68 20 61 20 6c 6f 6f 70 2e 20 54 68 65 |ough a loop. The| 000008c0 20 6c 6f 6f 70 20 73 74 61 72 74 73 20 66 72 6f | loop starts fro| 000008d0 6d 20 7a 65 72 6f 2e 20 54 68 69 73 20 20 2a 2f |m zero. This */| 000008e0 0a 2f 2a 20 69 73 20 64 65 6c 69 62 65 72 61 74 |./* is deliberat| 000008f0 65 2c 20 61 6e 64 20 69 73 20 62 65 63 61 75 73 |e, and is becaus| 00000900 65 20 6d 6f 73 74 20 66 69 6c 6d 73 20 61 63 74 |e most films act| 00000910 75 61 6c 6c 79 20 73 74 61 72 74 20 66 72 6f 6d |ually start from| 00000920 20 66 72 61 6d 65 20 20 20 20 2a 2f 0a 2f 2a 20 | frame */./* | 00000930 7a 65 72 6f 2c 20 75 6e 6c 65 73 73 20 79 6f 75 |zero, unless you| 00000940 20 67 65 74 20 6f 76 65 72 2d 65 6e 74 68 75 73 | get over-enthus| 00000950 69 61 73 74 69 63 20 77 68 69 6c 65 20 6c 6f 61 |iastic while loa| 00000960 64 69 6e 67 20 74 68 65 20 66 69 6c 6d 2e 20 20 |ding the film. | 00000970 20 20 20 20 20 20 2a 2f 0a 0a 20 20 66 6f 72 20 | */.. for | 00000980 28 69 3d 30 3b 20 69 3c 6d 61 78 5f 66 72 61 6d |(i=0; i<max_fram| 00000990 65 73 3b 20 69 2b 2b 29 0a 20 20 7b 20 70 72 69 |es; i++). { pri| 000009a0 6e 74 66 28 22 50 6c 65 61 73 65 20 65 6e 74 65 |ntf("Please ente| 000009b0 72 20 74 68 65 20 65 78 70 6f 73 75 72 65 20 6f |r the exposure o| 000009c0 66 20 66 72 61 6d 65 20 25 64 2e 5c 6e 22 2c 20 |f frame %d.\n", | 000009d0 69 29 3b 0a 20 20 20 20 73 63 61 6e 66 28 22 25 |i);. scanf("%| 000009e0 64 22 2c 20 65 78 70 6f 73 75 72 65 20 2b 20 69 |d", exposure + i| 000009f0 29 3b 0a 20 20 20 20 70 72 69 6e 74 66 28 22 50 |);. printf("P| 00000a00 6c 65 61 73 65 20 65 6e 74 65 72 20 74 68 65 20 |lease enter the | 00000a10 61 70 65 72 74 75 72 65 20 73 65 74 74 69 6e 67 |aperture setting| 00000a20 20 66 6f 72 20 66 72 61 6d 65 20 25 64 2e 5c 6e | for frame %d.\n| 00000a30 22 2c 20 69 29 3b 0a 2f 2a 20 54 68 65 20 61 70 |", i);./* The ap| 00000a40 65 72 74 75 72 65 20 69 73 20 72 65 61 64 20 61 |erture is read a| 00000a50 73 20 61 20 66 6c 6f 61 74 69 6e 67 20 70 6f 69 |s a floating poi| 00000a60 6e 74 20 6e 75 6d 62 65 72 2c 20 61 6e 64 20 74 |nt number, and t| 00000a70 68 65 20 69 6e 74 65 67 65 72 20 61 6e 64 20 20 |he integer and | 00000a80 2a 2f 0a 2f 2a 20 74 68 65 20 66 69 72 73 74 20 |*/./* the first | 00000a90 64 65 63 69 6d 61 6c 20 70 6c 61 63 65 20 70 61 |decimal place pa| 00000aa0 72 74 73 20 6f 66 20 74 68 65 20 6e 75 6d 62 65 |rts of the numbe| 00000ab0 72 20 61 72 65 20 68 65 6c 64 20 69 6e 20 65 6c |r are held in el| 00000ac0 65 6d 65 6e 74 73 20 7a 65 72 6f 20 2a 2f 0a 2f |ements zero */./| 00000ad0 2a 20 61 6e 64 20 6f 6e 65 20 6f 66 20 74 68 65 |* and one of the| 00000ae0 20 61 72 72 61 79 2e 20 54 68 65 20 64 6f 75 62 | array. The doub| 00000af0 6c 65 20 61 73 74 65 72 69 73 6b 20 6c 6f 6f 6b |le asterisk look| 00000b00 73 20 64 61 75 6e 74 69 6e 67 2c 20 62 75 74 20 |s daunting, but | 00000b10 77 6f 72 6b 73 2c 20 20 2a 2f 0a 2f 2a 20 73 69 |works, */./* si| 00000b20 6e 63 65 20 61 70 65 72 74 75 72 65 20 69 73 20 |nce aperture is | 00000b30 74 65 63 68 6e 69 63 61 6c 6c 79 20 61 20 70 6f |technically a po| 00000b40 69 6e 74 65 72 20 74 6f 20 61 20 70 6f 69 6e 74 |inter to a point| 00000b50 65 72 2e 20 20 20 20 20 20 20 20 20 20 20 20 20 |er. | 00000b60 20 20 20 20 2a 2f 0a 20 20 20 20 2a 28 61 70 65 | */. *(ape| 00000b70 72 74 75 72 65 20 2b 20 69 29 20 3d 20 6d 61 6c |rture + i) = mal| 00000b80 6c 6f 63 28 32 2a 73 69 7a 65 6f 66 28 69 6e 74 |loc(2*sizeof(int| 00000b90 29 29 3b 0a 20 20 20 20 73 63 61 6e 66 28 22 25 |));. scanf("%| 00000ba0 66 22 2c 26 64 61 74 75 6d 29 3b 0a 20 20 20 20 |f",&datum);. | 00000bb0 2a 2a 28 61 70 65 72 74 75 72 65 20 2b 20 69 29 |**(aperture + i)| 00000bc0 20 3d 20 28 69 6e 74 29 64 61 74 75 6d 3b 0a 20 | = (int)datum;. | 00000bd0 20 20 20 2a 28 2a 28 61 70 65 72 74 75 72 65 2b | *(*(aperture+| 00000be0 69 29 2b 31 29 20 3d 20 28 64 61 74 75 6d 20 2d |i)+1) = (datum -| 00000bf0 20 2a 2a 28 61 70 65 72 74 75 72 65 2b 69 29 29 | **(aperture+i))| 00000c00 20 2a 20 31 30 3b 0a 20 20 20 20 70 72 69 6e 74 | * 10;. print| 00000c10 66 28 22 50 6c 65 61 73 65 20 65 6e 74 65 72 20 |f("Please enter | 00000c20 74 68 65 20 6c 6f 63 74 69 6f 6e 20 66 6f 72 20 |the loction for | 00000c30 66 72 61 6d 65 20 25 64 2e 5c 6e 22 2c 69 29 3b |frame %d.\n",i);| 00000c40 0a 20 20 20 20 67 65 74 63 68 61 72 28 29 3b 0a |. getchar();.| 00000c50 2f 2a 20 54 68 65 20 67 65 74 73 28 29 20 66 75 |/* The gets() fu| 00000c60 6e 63 74 69 6f 6e 20 72 65 61 64 73 20 61 20 6c |nction reads a l| 00000c70 69 6e 65 20 6f 66 20 74 65 78 74 20 66 72 6f 6d |ine of text from| 00000c80 20 74 68 65 20 6b 65 79 62 6f 61 72 64 20 69 6e | the keyboard in| 00000c90 74 6f 20 61 20 20 20 20 20 2a 2f 0a 2f 2a 20 73 |to a */./* s| 00000ca0 74 72 69 6e 67 2e 20 49 74 20 74 61 6b 65 73 20 |tring. It takes | 00000cb0 61 73 20 61 6e 20 61 72 67 75 6d 65 6e 74 20 61 |as an argument a| 00000cc0 20 70 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 20 | pointer to the | 00000cd0 73 74 72 69 6e 67 2e 20 20 20 20 20 20 20 20 20 |string. | 00000ce0 20 20 20 20 20 2a 2f 0a 20 20 20 20 67 65 74 73 | */. gets| 00000cf0 28 62 75 66 66 65 72 29 3b 0a 2f 2a 20 73 74 72 |(buffer);./* str| 00000d00 6c 65 6e 28 29 20 72 65 74 75 72 6e 73 20 74 68 |len() returns th| 00000d10 65 20 6c 65 6e 67 74 68 20 6f 66 20 61 20 73 74 |e length of a st| 00000d20 72 69 6e 67 2e 20 49 74 20 64 6f 65 73 20 5f 6e |ring. It does _n| 00000d30 6f 74 5f 20 69 6e 63 6c 75 64 65 20 74 68 65 20 |ot_ include the | 00000d40 20 20 20 2a 2f 0a 2f 2a 20 74 65 72 6d 69 6e 61 | */./* termina| 00000d50 74 69 6e 67 20 7a 65 72 6f 20 62 79 74 65 2e 20 |ting zero byte. | 00000d60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000d80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a | *| 00000d90 2f 0a 20 20 20 20 6c 65 6e 20 3d 20 73 74 72 6c |/. len = strl| 00000da0 65 6e 28 62 75 66 66 65 72 29 3b 0a 2f 2a 20 53 |en(buffer);./* S| 00000db0 65 74 20 75 70 20 74 68 65 20 70 6f 69 6e 74 65 |et up the pointe| 00000dc0 72 20 69 6e 20 70 6c 61 63 65 5b 69 5d 20 74 6f |r in place[i] to| 00000dd0 20 70 6f 69 6e 74 20 74 6f 20 61 6e 20 61 72 65 | point to an are| 00000de0 61 20 62 69 67 20 65 6e 6f 75 67 68 20 74 6f 20 |a big enough to | 00000df0 68 6f 6c 64 20 2a 2f 0a 2f 2a 20 74 68 65 20 73 |hold */./* the s| 00000e00 74 72 69 6e 67 20 6a 75 73 74 20 69 6e 70 75 74 |tring just input| 00000e10 2e 20 4e 6f 74 65 3a 20 31 29 20 73 69 7a 65 6f |. Note: 1) sizeo| 00000e20 66 28 63 68 61 72 29 20 69 73 20 61 73 73 75 6d |f(char) is assum| 00000e30 65 64 20 74 6f 20 62 65 20 6f 6e 65 2c 20 73 6f |ed to be one, so| 00000e40 20 2a 2f 0a 2f 2a 20 6e 6f 74 20 6e 65 65 64 65 | */./* not neede| 00000e50 64 20 69 6e 20 74 68 65 20 6d 61 6c 6c 6f 63 28 |d in the malloc(| 00000e60 29 20 73 74 61 74 65 6d 65 6e 74 20 61 6e 64 20 |) statement and | 00000e70 32 29 20 74 68 65 20 62 6c 6f 63 6b 20 6d 75 73 |2) the block mus| 00000e80 74 20 62 65 20 6f 6e 65 20 20 20 20 20 2a 2f 0a |t be one */.| 00000e90 2f 2a 20 62 79 74 65 20 6c 6f 6e 67 65 72 20 74 |/* byte longer t| 00000ea0 68 61 6e 20 74 68 65 20 6e 75 6d 62 65 72 20 6f |han the number o| 00000eb0 66 20 63 68 61 72 61 63 74 65 72 73 20 69 6e 20 |f characters in | 00000ec0 74 68 65 20 73 74 72 69 6e 67 20 74 6f 20 61 6c |the string to al| 00000ed0 6c 6f 77 20 66 6f 72 20 20 2a 2f 0a 2f 2a 20 74 |low for */./* t| 00000ee0 68 65 20 74 65 72 6d 69 6e 61 74 69 6e 67 20 7a |he terminating z| 00000ef0 65 72 6f 2e 20 20 20 20 20 20 20 20 20 20 20 20 |ero. | 00000f00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000f20 20 20 20 20 20 2a 2f 0a 20 20 20 20 2a 28 70 6c | */. *(pl| 00000f30 61 63 65 2b 69 29 20 3d 20 6d 61 6c 6c 6f 63 28 |ace+i) = malloc(| 00000f40 6c 65 6e 2b 31 29 3b 0a 2f 2a 20 73 74 72 63 70 |len+1);./* strcp| 00000f50 79 28 29 20 63 6f 70 69 65 73 20 6f 6e 65 20 73 |y() copies one s| 00000f60 74 72 69 6e 67 20 74 6f 20 61 6e 6f 74 68 65 72 |tring to another| 00000f70 20 73 74 72 69 6e 67 20 2d 20 77 68 69 63 68 20 | string - which | 00000f80 63 61 6e 6e 6f 74 20 62 65 20 64 6f 6e 65 20 20 |cannot be done | 00000f90 20 2a 2f 0a 2f 2a 20 69 6e 20 43 20 62 79 20 61 | */./* in C by a| 00000fa0 20 73 69 6d 70 6c 65 20 73 74 72 69 6e 67 31 3d | simple string1=| 00000fb0 73 74 72 69 6e 67 32 20 63 6f 6d 6d 61 6e 64 2e |string2 command.| 00000fc0 20 49 6e 20 74 68 69 73 20 63 61 73 65 2c 20 74 | In this case, t| 00000fd0 68 65 20 73 74 72 69 6e 67 20 20 20 20 2a 2f 0a |he string */.| 00000fe0 2f 2a 20 70 6f 69 6e 74 65 64 20 74 6f 20 62 79 |/* pointed to by| 00000ff0 20 74 68 65 20 70 6f 69 6e 74 65 72 20 27 62 75 | the pointer 'bu| 00001000 66 66 65 72 27 20 69 73 20 63 6f 70 69 65 64 20 |ffer' is copied | 00001010 74 6f 20 74 68 65 20 6d 65 6d 6f 72 79 20 62 6c |to the memory bl| 00001020 6f 63 6b 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 70 |ock */./* p| 00001030 6f 69 6e 74 65 64 20 74 6f 20 62 79 20 74 68 65 |ointed to by the| 00001040 20 70 6f 69 6e 74 65 72 20 27 2a 28 70 6c 61 63 | pointer '*(plac| 00001050 65 2b 69 29 27 2e 20 54 68 65 20 63 6f 70 79 69 |e+i)'. The copyi| 00001060 6e 67 20 73 74 6f 70 73 20 77 68 65 6e 20 61 20 |ng stops when a | 00001070 20 20 20 20 20 2a 2f 0a 2f 2a 20 74 65 72 6d 69 | */./* termi| 00001080 6e 61 74 69 6e 67 20 7a 65 72 6f 20 69 73 20 65 |nating zero is e| 00001090 6e 6f 75 6e 74 65 72 65 64 20 69 6e 20 74 68 65 |nountered in the| 000010a0 20 73 74 72 69 6e 67 20 70 6f 69 6e 74 65 64 20 | string pointed | 000010b0 74 6f 20 62 79 20 62 75 66 66 65 72 2e 20 20 20 |to by buffer. | 000010c0 20 2a 2f 0a 20 20 20 20 73 74 72 63 70 79 28 2a | */. strcpy(*| 000010d0 28 70 6c 61 63 65 2b 69 29 2c 62 75 66 66 65 72 |(place+i),buffer| 000010e0 29 3b 0a 20 20 7d 0a 0a 2f 2a 20 54 68 65 20 6e |);. }../* The n| 000010f0 65 78 74 20 6c 6f 6f 70 20 70 72 69 6e 74 73 20 |ext loop prints | 00001100 6f 75 74 20 61 6c 6c 20 74 68 65 20 76 61 6c 75 |out all the valu| 00001110 65 73 20 74 68 61 74 20 77 65 20 68 61 76 65 20 |es that we have | 00001120 6a 75 73 74 20 69 6e 70 75 74 2e 20 20 20 20 20 |just input. | 00001130 20 2a 2f 0a 20 20 66 6f 72 20 28 69 3d 30 3b 20 | */. for (i=0; | 00001140 69 3c 6d 61 78 5f 66 72 61 6d 65 73 3b 20 69 2b |i<max_frames; i+| 00001150 2b 29 0a 20 20 7b 20 70 72 69 6e 74 66 28 22 45 |+). { printf("E| 00001160 78 70 6f 73 75 72 65 20 25 64 20 77 61 73 20 74 |xposure %d was t| 00001170 61 6b 65 6e 20 61 74 20 25 73 5c 6e 22 2c 69 2c |aken at %s\n",i,| 00001180 2a 28 70 6c 61 63 65 2b 69 29 29 3b 0a 20 20 20 |*(place+i));. | 00001190 20 69 66 20 28 2a 28 65 78 70 6f 73 75 72 65 2b | if (*(exposure+| 000011a0 69 29 20 3e 20 30 29 0a 20 20 20 20 7b 20 70 72 |i) > 0). { pr| 000011b0 69 6e 74 66 28 22 77 69 74 68 20 61 6e 20 65 78 |intf("with an ex| 000011c0 70 6f 73 75 72 65 20 6f 66 20 25 64 20 22 2c 2a |posure of %d ",*| 000011d0 28 65 78 70 6f 73 75 72 65 2b 69 29 29 3b 20 7d |(exposure+i)); }| 000011e0 20 65 6c 73 65 0a 20 20 20 20 7b 20 70 72 69 6e | else. { prin| 000011f0 74 66 28 22 77 69 74 68 20 61 6e 20 65 78 70 6f |tf("with an expo| 00001200 73 75 72 65 20 6f 66 20 31 2f 25 64 20 22 2c 2d |sure of 1/%d ",-| 00001210 2a 28 65 78 70 6f 73 75 72 65 2b 69 29 29 3b 20 |*(exposure+i)); | 00001220 7d 0a 20 20 20 20 70 72 69 6e 74 66 28 22 61 6e |}. printf("an| 00001230 64 20 61 6e 20 61 70 65 72 74 75 72 65 20 6f 66 |d an aperture of| 00001240 20 25 64 2e 25 64 2e 5c 6e 5c 6e 22 2c 2a 2a 28 | %d.%d.\n\n",**(| 00001250 61 70 65 72 74 75 72 65 2b 69 29 2c 0a 20 20 20 |aperture+i),. | 00001260 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00001280 20 20 20 20 20 20 20 20 2a 28 2a 28 61 70 65 72 | *(*(aper| 00001290 74 75 72 65 2b 69 29 2b 31 29 29 3b 0a 20 20 7d |ture+i)+1));. }| 000012a0 0a 2f 2a 20 53 69 6e 63 65 20 6d 61 69 6e 28 29 |./* Since main()| 000012b0 20 69 73 20 74 65 63 68 6e 69 63 61 6c 6c 79 20 | is technically | 000012c0 61 20 66 75 6e 63 74 69 6f 6e 2c 20 77 65 20 73 |a function, we s| 000012d0 68 6f 75 6c 64 20 72 65 74 75 72 6e 20 7a 65 72 |hould return zer| 000012e0 6f 20 66 72 6f 6d 20 20 20 20 2a 2f 0a 2f 2a 20 |o from */./* | 000012f0 69 74 20 74 6f 20 72 65 61 73 73 75 72 65 20 74 |it to reassure t| 00001300 68 65 20 6d 61 63 68 69 6e 65 20 74 68 61 74 20 |he machine that | 00001310 65 76 65 72 79 74 68 69 6e 67 20 68 61 73 20 67 |everything has g| 00001320 6f 6e 65 20 77 65 6c 6c 2e 20 44 6f 6e 27 74 20 |one well. Don't | 00001330 20 20 20 20 20 20 2a 2f 0a 2f 2a 20 77 6f 72 72 | */./* worr| 00001340 79 20 61 62 6f 75 74 20 74 68 69 73 20 66 6f 72 |y about this for| 00001350 20 74 68 65 20 6d 6f 6d 65 6e 74 2e 20 20 20 20 | the moment. | 00001360 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00001380 20 20 2a 2f 0a 20 20 72 65 74 75 72 6e 20 30 3b | */. return 0;| 00001390 0a 7d 0a |.}.| 00001393