Home » Archimedes archive » Acorn User » AU 1995-01.adf » !C_C » c/Humpty
c/Humpty
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/Humpty |
Read OK: | ✔ |
File size: | 0DD9 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
/* Humpty: a file to print out information about various */ /* types of variables. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> main() { int i,j; int *pint, intlist[10]; char character, *string; double number, numlist[3]; i = 42; pint = &i; for (j=0; j<10; j++) intlist[j] = 11 * j; character = 'Q'; string = malloc(11); strcpy(string,"Acorn User"); numlist[0] = sqrt(2.0); numlist[1] = 0.75; numlist[2] = 1.6e-19; number = numlist[0]; printf("Type Return to move to the next variable.\n\n"); printf("The variable 'i':\n"); printf("The name of the variable is 'i', its value is %d,\n", i); printf("it has type 'int' and its address is %d.\n\n", (int)&i); getchar(); printf("The variable 'pint':\n"); printf("The name of the variable is 'pint', its value is %d,\n",(int)pint); printf("it has type 'pointer to int' and its address is %d\n\n", (int)&pint); printf("Note that the value of pint is the same as the address\n"); printf("of i, as expected.\n\n"); getchar(); printf("The array 'intlist[]':\n"); printf("The name of the array is 'intlist[]', it has\n"); printf("a set of values:\n"); for (j=0; j<10; j++) printf("%d\n", intlist[j]); printf("it has type 'array of int' and occupies a range of\n"); printf("addresses from %d to %d.\n\n", (int)&intlist[0], (int)&intlist[9]); getchar(); printf("The variable 'intlist':\n"); printf("The name of the variable is 'intlist', its value is %d,\n", (int)intlist); printf("it has type 'pointer to int' and its�address is %d.\n\n", (int)&intlist); printf("Note that the value of 'intlist' is the base address of\n"); printf("'intlist[]', and is also the address of the pointer\n"); printf("'intlist'. In other words, the pointer points to itself.\n"); printf("This is because the 'intlist' was declared as an array,\n"); printf("and was allocated space immediately it was declared.\n\n"); getchar(); printf("The variable 'character':\n"); printf("The name of the variable is 'character', its value is %c,\n", character); printf("if has type 'char' and its address is %d.\n\n", (int)&character); getchar(); printf("The array 'string[]':\n"); printf("The name of the array is 'string[]', its value is %s,\n",string); printf("it has type 'array of char' and occupies a range of\n"); printf("addresses from %d to %d.\n\n", (int)&string[0], (int)&string[10]); getchar(); printf("The variable 'string':\n"); printf("The name of the variable is 'string', its value is %d,\n", (int)string); printf("it has type 'pointer to char' and its�address is %d.\n\n", (int)&string); printf("Note that the value of 'string' is the base address of\n"); printf("'string[]', but in this case is *not* the address of\n"); printf("'string'. This is a consequence of declaring 'string'\n"); printf("as a pointer and initialising it with a malloc(), rather\n"); printf("than declaring it as an array.\n\n"); getchar(); printf("The variable 'numlist[0]':\n"); printf("The name of the variable is 'numlist[0]', its value is %f,\n", numlist[0]); printf("it has type 'float' and its address is %d.\n\n", (int)&numlist[0]); getchar(); printf("The variable 'number':\n"); printf("The name of the variable is 'number', its value is %f,\n", number); printf("it has type 'float' and its address is %d.\n\n", (int)&number); return 0; }
00000000 2f 2a 20 48 75 6d 70 74 79 3a 20 61 20 66 69 6c |/* Humpty: a fil| 00000010 65 20 74 6f 20 70 72 69 6e 74 20 6f 75 74 20 69 |e to print out i| 00000020 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 |nformation about| 00000030 20 76 61 72 69 6f 75 73 20 2a 2f 0a 2f 2a 20 74 | various */./* t| 00000040 79 70 65 73 20 6f 66 20 76 61 72 69 61 62 6c 65 |ypes of variable| 00000050 73 2e 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |s. | 00000060 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000070 20 20 20 20 20 2a 2f 0a 0a 23 69 6e 63 6c 75 64 | */..#includ| 00000080 65 20 3c 73 74 64 69 6f 2e 68 3e 0a 23 69 6e 63 |e <stdio.h>.#inc| 00000090 6c 75 64 65 20 3c 73 74 64 6c 69 62 2e 68 3e 0a |lude <stdlib.h>.| 000000a0 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 72 69 6e |.#include <strin| 000000b0 67 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 6d |g.h>.#include <m| 000000c0 61 74 68 2e 68 3e 0a 0a 6d 61 69 6e 28 29 0a 7b |ath.h>..main().{| 000000d0 20 69 6e 74 20 69 2c 6a 3b 0a 20 20 69 6e 74 20 | int i,j;. int | 000000e0 2a 70 69 6e 74 2c 20 69 6e 74 6c 69 73 74 5b 31 |*pint, intlist[1| 000000f0 30 5d 3b 0a 20 20 63 68 61 72 20 63 68 61 72 61 |0];. char chara| 00000100 63 74 65 72 2c 20 2a 73 74 72 69 6e 67 3b 0a 20 |cter, *string;. | 00000110 20 64 6f 75 62 6c 65 20 6e 75 6d 62 65 72 2c 20 | double number, | 00000120 6e 75 6d 6c 69 73 74 5b 33 5d 3b 0a 0a 20 20 69 |numlist[3];.. i| 00000130 20 3d 20 34 32 3b 0a 20 20 70 69 6e 74 20 3d 20 | = 42;. pint = | 00000140 26 69 3b 0a 20 20 66 6f 72 20 28 6a 3d 30 3b 20 |&i;. for (j=0; | 00000150 6a 3c 31 30 3b 20 6a 2b 2b 29 20 69 6e 74 6c 69 |j<10; j++) intli| 00000160 73 74 5b 6a 5d 20 3d 20 31 31 20 2a 20 6a 3b 0a |st[j] = 11 * j;.| 00000170 20 20 63 68 61 72 61 63 74 65 72 20 3d 20 27 51 | character = 'Q| 00000180 27 3b 0a 20 20 73 74 72 69 6e 67 20 3d 20 6d 61 |';. string = ma| 00000190 6c 6c 6f 63 28 31 31 29 3b 0a 20 20 73 74 72 63 |lloc(11);. strc| 000001a0 70 79 28 73 74 72 69 6e 67 2c 22 41 63 6f 72 6e |py(string,"Acorn| 000001b0 20 55 73 65 72 22 29 3b 0a 20 20 6e 75 6d 6c 69 | User");. numli| 000001c0 73 74 5b 30 5d 20 3d 20 73 71 72 74 28 32 2e 30 |st[0] = sqrt(2.0| 000001d0 29 3b 0a 20 20 6e 75 6d 6c 69 73 74 5b 31 5d 20 |);. numlist[1] | 000001e0 3d 20 30 2e 37 35 3b 0a 20 20 6e 75 6d 6c 69 73 |= 0.75;. numlis| 000001f0 74 5b 32 5d 20 3d 20 31 2e 36 65 2d 31 39 3b 0a |t[2] = 1.6e-19;.| 00000200 20 20 6e 75 6d 62 65 72 20 3d 20 6e 75 6d 6c 69 | number = numli| 00000210 73 74 5b 30 5d 3b 0a 0a 20 20 70 72 69 6e 74 66 |st[0];.. printf| 00000220 28 22 54 79 70 65 20 52 65 74 75 72 6e 20 74 6f |("Type Return to| 00000230 20 6d 6f 76 65 20 74 6f 20 74 68 65 20 6e 65 78 | move to the nex| 00000240 74 20 76 61 72 69 61 62 6c 65 2e 5c 6e 5c 6e 22 |t variable.\n\n"| 00000250 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 54 68 65 |);. printf("The| 00000260 20 76 61 72 69 61 62 6c 65 20 27 69 27 3a 5c 6e | variable 'i':\n| 00000270 22 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 54 68 |");. printf("Th| 00000280 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 76 61 |e name of the va| 00000290 72 69 61 62 6c 65 20 69 73 20 27 69 27 2c 20 69 |riable is 'i', i| 000002a0 74 73 20 76 61 6c 75 65 20 69 73 20 25 64 2c 5c |ts value is %d,\| 000002b0 6e 22 2c 20 69 29 3b 0a 20 20 70 72 69 6e 74 66 |n", i);. printf| 000002c0 28 22 69 74 20 68 61 73 20 74 79 70 65 20 27 69 |("it has type 'i| 000002d0 6e 74 27 20 61 6e 64 20 69 74 73 20 61 64 64 72 |nt' and its addr| 000002e0 65 73 73 20 69 73 20 25 64 2e 5c 6e 5c 6e 22 2c |ess is %d.\n\n",| 000002f0 20 28 69 6e 74 29 26 69 29 3b 0a 20 20 67 65 74 | (int)&i);. get| 00000300 63 68 61 72 28 29 3b 0a 20 20 70 72 69 6e 74 66 |char();. printf| 00000310 28 22 54 68 65 20 76 61 72 69 61 62 6c 65 20 27 |("The variable '| 00000320 70 69 6e 74 27 3a 5c 6e 22 29 3b 0a 20 20 70 72 |pint':\n");. pr| 00000330 69 6e 74 66 28 22 54 68 65 20 6e 61 6d 65 20 6f |intf("The name o| 00000340 66 20 74 68 65 20 76 61 72 69 61 62 6c 65 20 69 |f the variable i| 00000350 73 20 27 70 69 6e 74 27 2c 20 69 74 73 20 76 61 |s 'pint', its va| 00000360 6c 75 65 20 69 73 20 25 64 2c 5c 6e 22 2c 28 69 |lue is %d,\n",(i| 00000370 6e 74 29 70 69 6e 74 29 3b 0a 20 20 70 72 69 6e |nt)pint);. prin| 00000380 74 66 28 22 69 74 20 68 61 73 20 74 79 70 65 20 |tf("it has type | 00000390 27 70 6f 69 6e 74 65 72 20 74 6f 20 69 6e 74 27 |'pointer to int'| 000003a0 20 61 6e 64 20 69 74 73 20 61 64 64 72 65 73 73 | and its address| 000003b0 20 69 73 20 25 64 5c 6e 5c 6e 22 2c 0a 20 20 20 | is %d\n\n",. | 000003c0 20 20 20 20 20 20 20 28 69 6e 74 29 26 70 69 6e | (int)&pin| 000003d0 74 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 4e 6f |t);. printf("No| 000003e0 74 65 20 74 68 61 74 20 74 68 65 20 76 61 6c 75 |te that the valu| 000003f0 65 20 6f 66 20 70 69 6e 74 20 69 73 20 74 68 65 |e of pint is the| 00000400 20 73 61 6d 65 20 61 73 20 74 68 65 20 61 64 64 | same as the add| 00000410 72 65 73 73 5c 6e 22 29 3b 0a 20 20 70 72 69 6e |ress\n");. prin| 00000420 74 66 28 22 6f 66 20 69 2c 20 61 73 20 65 78 70 |tf("of i, as exp| 00000430 65 63 74 65 64 2e 5c 6e 5c 6e 22 29 3b 0a 20 20 |ected.\n\n");. | 00000440 67 65 74 63 68 61 72 28 29 3b 0a 20 20 70 72 69 |getchar();. pri| 00000450 6e 74 66 28 22 54 68 65 20 61 72 72 61 79 20 27 |ntf("The array '| 00000460 69 6e 74 6c 69 73 74 5b 5d 27 3a 5c 6e 22 29 3b |intlist[]':\n");| 00000470 0a 20 20 70 72 69 6e 74 66 28 22 54 68 65 20 6e |. printf("The n| 00000480 61 6d 65 20 6f 66 20 74 68 65 20 61 72 72 61 79 |ame of the array| 00000490 20 69 73 20 27 69 6e 74 6c 69 73 74 5b 5d 27 2c | is 'intlist[]',| 000004a0 20 69 74 20 68 61 73 5c 6e 22 29 3b 0a 20 20 70 | it has\n");. p| 000004b0 72 69 6e 74 66 28 22 61 20 73 65 74 20 6f 66 20 |rintf("a set of | 000004c0 76 61 6c 75 65 73 3a 5c 6e 22 29 3b 0a 20 20 66 |values:\n");. f| 000004d0 6f 72 20 28 6a 3d 30 3b 20 6a 3c 31 30 3b 20 6a |or (j=0; j<10; j| 000004e0 2b 2b 29 20 70 72 69 6e 74 66 28 22 25 64 5c 6e |++) printf("%d\n| 000004f0 22 2c 20 69 6e 74 6c 69 73 74 5b 6a 5d 29 3b 0a |", intlist[j]);.| 00000500 20 20 70 72 69 6e 74 66 28 22 69 74 20 68 61 73 | printf("it has| 00000510 20 74 79 70 65 20 27 61 72 72 61 79 20 6f 66 20 | type 'array of | 00000520 69 6e 74 27 20 61 6e 64 20 6f 63 63 75 70 69 65 |int' and occupie| 00000530 73 20 61 20 72 61 6e 67 65 20 6f 66 5c 6e 22 29 |s a range of\n")| 00000540 3b 0a 20 20 70 72 69 6e 74 66 28 22 61 64 64 72 |;. printf("addr| 00000550 65 73 73 65 73 20 66 72 6f 6d 20 25 64 20 74 6f |esses from %d to| 00000560 20 25 64 2e 5c 6e 5c 6e 22 2c 0a 20 20 20 20 20 | %d.\n\n",. | 00000570 20 20 20 20 20 28 69 6e 74 29 26 69 6e 74 6c 69 | (int)&intli| 00000580 73 74 5b 30 5d 2c 20 28 69 6e 74 29 26 69 6e 74 |st[0], (int)&int| 00000590 6c 69 73 74 5b 39 5d 29 3b 0a 20 20 67 65 74 63 |list[9]);. getc| 000005a0 68 61 72 28 29 3b 0a 20 20 70 72 69 6e 74 66 28 |har();. printf(| 000005b0 22 54 68 65 20 76 61 72 69 61 62 6c 65 20 27 69 |"The variable 'i| 000005c0 6e 74 6c 69 73 74 27 3a 5c 6e 22 29 3b 0a 20 20 |ntlist':\n");. | 000005d0 70 72 69 6e 74 66 28 22 54 68 65 20 6e 61 6d 65 |printf("The name| 000005e0 20 6f 66 20 74 68 65 20 76 61 72 69 61 62 6c 65 | of the variable| 000005f0 20 69 73 20 27 69 6e 74 6c 69 73 74 27 2c 20 69 | is 'intlist', i| 00000600 74 73 20 76 61 6c 75 65 20 69 73 20 25 64 2c 5c |ts value is %d,\| 00000610 6e 22 2c 0a 20 20 20 20 20 20 20 20 20 20 28 69 |n",. (i| 00000620 6e 74 29 69 6e 74 6c 69 73 74 29 3b 0a 20 20 70 |nt)intlist);. p| 00000630 72 69 6e 74 66 28 22 69 74 20 68 61 73 20 74 79 |rintf("it has ty| 00000640 70 65 20 27 70 6f 69 6e 74 65 72 20 74 6f 20 69 |pe 'pointer to i| 00000650 6e 74 27 20 61 6e 64 20 69 74 73 a0 61 64 64 72 |nt' and its.addr| 00000660 65 73 73 20 69 73 20 25 64 2e 5c 6e 5c 6e 22 2c |ess is %d.\n\n",| 00000670 0a 20 20 20 20 20 20 20 20 20 20 28 69 6e 74 29 |. (int)| 00000680 26 69 6e 74 6c 69 73 74 29 3b 0a 20 20 70 72 69 |&intlist);. pri| 00000690 6e 74 66 28 22 4e 6f 74 65 20 74 68 61 74 20 74 |ntf("Note that t| 000006a0 68 65 20 76 61 6c 75 65 20 6f 66 20 27 69 6e 74 |he value of 'int| 000006b0 6c 69 73 74 27 20 69 73 20 74 68 65 20 62 61 73 |list' is the bas| 000006c0 65 20 61 64 64 72 65 73 73 20 6f 66 5c 6e 22 29 |e address of\n")| 000006d0 3b 0a 20 20 70 72 69 6e 74 66 28 22 27 69 6e 74 |;. printf("'int| 000006e0 6c 69 73 74 5b 5d 27 2c 20 61 6e 64 20 69 73 20 |list[]', and is | 000006f0 61 6c 73 6f 20 74 68 65 20 61 64 64 72 65 73 73 |also the address| 00000700 20 6f 66 20 74 68 65 20 70 6f 69 6e 74 65 72 5c | of the pointer\| 00000710 6e 22 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 27 |n");. printf("'| 00000720 69 6e 74 6c 69 73 74 27 2e 20 49 6e 20 6f 74 68 |intlist'. In oth| 00000730 65 72 20 77 6f 72 64 73 2c 20 74 68 65 20 70 6f |er words, the po| 00000740 69 6e 74 65 72 20 70 6f 69 6e 74 73 20 74 6f 20 |inter points to | 00000750 69 74 73 65 6c 66 2e 5c 6e 22 29 3b 0a 20 20 70 |itself.\n");. p| 00000760 72 69 6e 74 66 28 22 54 68 69 73 20 69 73 20 62 |rintf("This is b| 00000770 65 63 61 75 73 65 20 74 68 65 20 27 69 6e 74 6c |ecause the 'intl| 00000780 69 73 74 27 20 77 61 73 20 64 65 63 6c 61 72 65 |ist' was declare| 00000790 64 20 61 73 20 61 6e 20 61 72 72 61 79 2c 5c 6e |d as an array,\n| 000007a0 22 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 61 6e |");. printf("an| 000007b0 64 20 77 61 73 20 61 6c 6c 6f 63 61 74 65 64 20 |d was allocated | 000007c0 73 70 61 63 65 20 69 6d 6d 65 64 69 61 74 65 6c |space immediatel| 000007d0 79 20 69 74 20 77 61 73 20 64 65 63 6c 61 72 65 |y it was declare| 000007e0 64 2e 5c 6e 5c 6e 22 29 3b 0a 20 20 67 65 74 63 |d.\n\n");. getc| 000007f0 68 61 72 28 29 3b 0a 20 20 70 72 69 6e 74 66 28 |har();. printf(| 00000800 22 54 68 65 20 76 61 72 69 61 62 6c 65 20 27 63 |"The variable 'c| 00000810 68 61 72 61 63 74 65 72 27 3a 5c 6e 22 29 3b 0a |haracter':\n");.| 00000820 20 20 70 72 69 6e 74 66 28 22 54 68 65 20 6e 61 | printf("The na| 00000830 6d 65 20 6f 66 20 74 68 65 20 76 61 72 69 61 62 |me of the variab| 00000840 6c 65 20 69 73 20 27 63 68 61 72 61 63 74 65 72 |le is 'character| 00000850 27 2c 20 69 74 73 20 76 61 6c 75 65 20 69 73 20 |', its value is | 00000860 25 63 2c 5c 6e 22 2c 0a 20 20 20 20 20 20 20 20 |%c,\n",. | 00000870 20 20 20 63 68 61 72 61 63 74 65 72 29 3b 0a 20 | character);. | 00000880 20 70 72 69 6e 74 66 28 22 69 66 20 68 61 73 20 | printf("if has | 00000890 74 79 70 65 20 27 63 68 61 72 27 20 61 6e 64 20 |type 'char' and | 000008a0 69 74 73 20 61 64 64 72 65 73 73 20 69 73 20 25 |its address is %| 000008b0 64 2e 5c 6e 5c 6e 22 2c 20 28 69 6e 74 29 26 63 |d.\n\n", (int)&c| 000008c0 68 61 72 61 63 74 65 72 29 3b 0a 20 20 67 65 74 |haracter);. get| 000008d0 63 68 61 72 28 29 3b 0a 20 20 70 72 69 6e 74 66 |char();. printf| 000008e0 28 22 54 68 65 20 61 72 72 61 79 20 27 73 74 72 |("The array 'str| 000008f0 69 6e 67 5b 5d 27 3a 5c 6e 22 29 3b 0a 20 20 70 |ing[]':\n");. p| 00000900 72 69 6e 74 66 28 22 54 68 65 20 6e 61 6d 65 20 |rintf("The name | 00000910 6f 66 20 74 68 65 20 61 72 72 61 79 20 69 73 20 |of the array is | 00000920 27 73 74 72 69 6e 67 5b 5d 27 2c 20 69 74 73 20 |'string[]', its | 00000930 76 61 6c 75 65 20 69 73 20 25 73 2c 5c 6e 22 2c |value is %s,\n",| 00000940 73 74 72 69 6e 67 29 3b 0a 20 20 70 72 69 6e 74 |string);. print| 00000950 66 28 22 69 74 20 68 61 73 20 74 79 70 65 20 27 |f("it has type '| 00000960 61 72 72 61 79 20 6f 66 20 63 68 61 72 27 20 61 |array of char' a| 00000970 6e 64 20 6f 63 63 75 70 69 65 73 20 61 20 72 61 |nd occupies a ra| 00000980 6e 67 65 20 6f 66 5c 6e 22 29 3b 0a 20 20 70 72 |nge of\n");. pr| 00000990 69 6e 74 66 28 22 61 64 64 72 65 73 73 65 73 20 |intf("addresses | 000009a0 66 72 6f 6d 20 25 64 20 74 6f 20 25 64 2e 5c 6e |from %d to %d.\n| 000009b0 5c 6e 22 2c 20 28 69 6e 74 29 26 73 74 72 69 6e |\n", (int)&strin| 000009c0 67 5b 30 5d 2c 20 28 69 6e 74 29 26 73 74 72 69 |g[0], (int)&stri| 000009d0 6e 67 5b 31 30 5d 29 3b 0a 20 20 67 65 74 63 68 |ng[10]);. getch| 000009e0 61 72 28 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 |ar();. printf("| 000009f0 54 68 65 20 76 61 72 69 61 62 6c 65 20 27 73 74 |The variable 'st| 00000a00 72 69 6e 67 27 3a 5c 6e 22 29 3b 0a 20 20 70 72 |ring':\n");. pr| 00000a10 69 6e 74 66 28 22 54 68 65 20 6e 61 6d 65 20 6f |intf("The name o| 00000a20 66 20 74 68 65 20 76 61 72 69 61 62 6c 65 20 69 |f the variable i| 00000a30 73 20 27 73 74 72 69 6e 67 27 2c 20 69 74 73 20 |s 'string', its | 00000a40 76 61 6c 75 65 20 69 73 20 25 64 2c 5c 6e 22 2c |value is %d,\n",| 00000a50 0a 20 20 20 20 20 20 20 20 20 20 28 69 6e 74 29 |. (int)| 00000a60 73 74 72 69 6e 67 29 3b 0a 20 20 70 72 69 6e 74 |string);. print| 00000a70 66 28 22 69 74 20 68 61 73 20 74 79 70 65 20 27 |f("it has type '| 00000a80 70 6f 69 6e 74 65 72 20 74 6f 20 63 68 61 72 27 |pointer to char'| 00000a90 20 61 6e 64 20 69 74 73 a0 61 64 64 72 65 73 73 | and its.address| 00000aa0 20 69 73 20 25 64 2e 5c 6e 5c 6e 22 2c 0a 20 20 | is %d.\n\n",. | 00000ab0 20 20 20 20 20 20 20 20 28 69 6e 74 29 26 73 74 | (int)&st| 00000ac0 72 69 6e 67 29 3b 0a 20 20 70 72 69 6e 74 66 28 |ring);. printf(| 00000ad0 22 4e 6f 74 65 20 74 68 61 74 20 74 68 65 20 76 |"Note that the v| 00000ae0 61 6c 75 65 20 6f 66 20 27 73 74 72 69 6e 67 27 |alue of 'string'| 00000af0 20 69 73 20 74 68 65 20 62 61 73 65 20 61 64 64 | is the base add| 00000b00 72 65 73 73 20 6f 66 5c 6e 22 29 3b 0a 20 20 70 |ress of\n");. p| 00000b10 72 69 6e 74 66 28 22 27 73 74 72 69 6e 67 5b 5d |rintf("'string[]| 00000b20 27 2c 20 62 75 74 20 69 6e 20 74 68 69 73 20 63 |', but in this c| 00000b30 61 73 65 20 69 73 20 2a 6e 6f 74 2a 20 74 68 65 |ase is *not* the| 00000b40 20 61 64 64 72 65 73 73 20 6f 66 5c 6e 22 29 3b | address of\n");| 00000b50 0a 20 20 70 72 69 6e 74 66 28 22 27 73 74 72 69 |. printf("'stri| 00000b60 6e 67 27 2e 20 54 68 69 73 20 69 73 20 61 20 63 |ng'. This is a c| 00000b70 6f 6e 73 65 71 75 65 6e 63 65 20 6f 66 20 64 65 |onsequence of de| 00000b80 63 6c 61 72 69 6e 67 20 27 73 74 72 69 6e 67 27 |claring 'string'| 00000b90 5c 6e 22 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 |\n");. printf("| 00000ba0 61 73 20 61 20 70 6f 69 6e 74 65 72 20 61 6e 64 |as a pointer and| 00000bb0 20 69 6e 69 74 69 61 6c 69 73 69 6e 67 20 69 74 | initialising it| 00000bc0 20 77 69 74 68 20 61 20 6d 61 6c 6c 6f 63 28 29 | with a malloc()| 00000bd0 2c 20 72 61 74 68 65 72 5c 6e 22 29 3b 0a 20 20 |, rather\n");. | 00000be0 70 72 69 6e 74 66 28 22 74 68 61 6e 20 64 65 63 |printf("than dec| 00000bf0 6c 61 72 69 6e 67 20 69 74 20 61 73 20 61 6e 20 |laring it as an | 00000c00 61 72 72 61 79 2e 5c 6e 5c 6e 22 29 3b 0a 20 20 |array.\n\n");. | 00000c10 67 65 74 63 68 61 72 28 29 3b 0a 20 20 70 72 69 |getchar();. pri| 00000c20 6e 74 66 28 22 54 68 65 20 76 61 72 69 61 62 6c |ntf("The variabl| 00000c30 65 20 27 6e 75 6d 6c 69 73 74 5b 30 5d 27 3a 5c |e 'numlist[0]':\| 00000c40 6e 22 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 54 |n");. printf("T| 00000c50 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 76 |he name of the v| 00000c60 61 72 69 61 62 6c 65 20 69 73 20 27 6e 75 6d 6c |ariable is 'numl| 00000c70 69 73 74 5b 30 5d 27 2c 20 69 74 73 20 76 61 6c |ist[0]', its val| 00000c80 75 65 20 69 73 20 25 66 2c 5c 6e 22 2c 0a 20 20 |ue is %f,\n",. | 00000c90 20 20 20 20 20 20 20 20 20 6e 75 6d 6c 69 73 74 | numlist| 00000ca0 5b 30 5d 29 3b 0a 20 20 70 72 69 6e 74 66 28 22 |[0]);. printf("| 00000cb0 69 74 20 68 61 73 20 74 79 70 65 20 27 66 6c 6f |it has type 'flo| 00000cc0 61 74 27 20 61 6e 64 20 69 74 73 20 61 64 64 72 |at' and its addr| 00000cd0 65 73 73 20 69 73 20 25 64 2e 5c 6e 5c 6e 22 2c |ess is %d.\n\n",| 00000ce0 20 28 69 6e 74 29 26 6e 75 6d 6c 69 73 74 5b 30 | (int)&numlist[0| 00000cf0 5d 29 3b 0a 20 20 67 65 74 63 68 61 72 28 29 3b |]);. getchar();| 00000d00 0a 20 20 70 72 69 6e 74 66 28 22 54 68 65 20 76 |. printf("The v| 00000d10 61 72 69 61 62 6c 65 20 27 6e 75 6d 62 65 72 27 |ariable 'number'| 00000d20 3a 5c 6e 22 29 3b 0a 20 20 70 72 69 6e 74 66 28 |:\n");. printf(| 00000d30 22 54 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 |"The name of the| 00000d40 20 76 61 72 69 61 62 6c 65 20 69 73 20 27 6e 75 | variable is 'nu| 00000d50 6d 62 65 72 27 2c 20 69 74 73 20 76 61 6c 75 65 |mber', its value| 00000d60 20 69 73 20 25 66 2c 5c 6e 22 2c 0a 20 20 20 20 | is %f,\n",. | 00000d70 20 20 20 20 20 20 20 6e 75 6d 62 65 72 29 3b 0a | number);.| 00000d80 20 20 70 72 69 6e 74 66 28 22 69 74 20 68 61 73 | printf("it has| 00000d90 20 74 79 70 65 20 27 66 6c 6f 61 74 27 20 61 6e | type 'float' an| 00000da0 64 20 69 74 73 20 61 64 64 72 65 73 73 20 69 73 |d its address is| 00000db0 20 25 64 2e 5c 6e 5c 6e 22 2c 20 28 69 6e 74 29 | %d.\n\n", (int)| 00000dc0 26 6e 75 6d 62 65 72 29 3b 0a 20 20 72 65 74 75 |&number);. retu| 00000dd0 72 6e 20 30 3b 0a 7d 0a 0a |rn 0;.}..| 00000dd9