home *** CD-ROM | disk | FTP | other *** search
/ Sams Teach Yourself C in 21 Days (6th Edition) / STYC216E.ISO / mac / Examples / Day20 / realloc.c < prev    next >
MacBinary  |  2002-08-11  |  1.4 KB  |  [TEXT/LMAN]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Sun Aug 11 11:26:26 2002, modified Sun Aug 11 11:26:26 2002, creator 'LMAN', type ASCII, 802 bytes "realloc.c" , at 0x3a2 286 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[LMAN]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 09 72 65 61 6c 6c 6f | 63 2e 63 00 00 00 00 00 |..reallo|c.c.....|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4c 4d 41 | 4e 00 00 ff ff ff ff 00 |.TEXTLMA|N.......|
|00000050| 00 00 00 00 00 03 22 00 | 00 01 1e b9 7c 32 a2 b9 |......".|....|2..|
|00000060| 7c 32 a2 00 00 00 00 00 | 00 00 00 00 00 00 00 00 ||2......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 70 69 00 00 |........|....pi..|
|00000080| 2f 2a 20 55 73 69 6e 67 | 20 72 65 61 6c 6c 6f 63 |/* Using| realloc|
|00000090| 28 29 20 74 6f 20 63 68 | 61 6e 67 65 20 6d 65 6d |() to ch|ange mem|
|000000a0| 6f 72 79 20 61 6c 6c 6f | 63 61 74 69 6f 6e 2e 20 |ory allo|cation. |
|000000b0| 2a 2f 0d 0a 0d 0a 23 69 | 6e 63 6c 75 64 65 20 3c |*/....#i|nclude <|
|000000c0| 73 74 64 69 6f 2e 68 3e | 0d 0a 23 69 6e 63 6c 75 |stdio.h>|..#inclu|
|000000d0| 64 65 20 3c 73 74 64 6c | 69 62 2e 68 3e 0d 0a 23 |de <stdl|ib.h>..#|
|000000e0| 69 6e 63 6c 75 64 65 20 | 3c 73 74 72 69 6e 67 2e |include |<string.|
|000000f0| 68 3e 0d 0a 0d 0a 69 6e | 74 20 6d 61 69 6e 28 20 |h>....in|t main( |
|00000100| 76 6f 69 64 20 29 0d 0a | 7b 0d 0a 20 20 20 20 63 |void )..|{.. c|
|00000110| 68 61 72 20 62 75 66 5b | 38 30 5d 2c 20 2a 6d 65 |har buf[|80], *me|
|00000120| 73 73 61 67 65 3b 0d 0a | 0d 0a 20 20 20 20 2f 2a |ssage;..|.. /*|
|00000130| 20 49 6e 70 75 74 20 61 | 20 73 74 72 69 6e 67 2e | Input a| string.|
|00000140| 20 2a 2f 0d 0a 0d 0a 20 | 20 20 20 70 75 74 73 28 | */.... | puts(|
|00000150| 22 45 6e 74 65 72 20 61 | 20 6c 69 6e 65 20 6f 66 |"Enter a| line of|
|00000160| 20 74 65 78 74 2e 22 29 | 3b 0d 0a 20 20 20 20 67 | text.")|;.. g|
|00000170| 65 74 73 28 62 75 66 29 | 3b 0d 0a 0d 0a 20 20 20 |ets(buf)|;.... |
|00000180| 20 2f 2a 20 41 6c 6c 6f | 63 61 74 65 20 74 68 65 | /* Allo|cate the|
|00000190| 20 69 6e 69 74 69 61 6c | 20 62 6c 6f 63 6b 20 61 | initial| block a|
|000001a0| 6e 64 20 63 6f 70 79 20 | 74 68 65 20 73 74 72 69 |nd copy |the stri|
|000001b0| 6e 67 20 74 6f 20 69 74 | 2e 20 2a 2f 0d 0a 0d 0a |ng to it|. */....|
|000001c0| 20 20 20 20 6d 65 73 73 | 61 67 65 20 3d 20 72 65 | mess|age = re|
|000001d0| 61 6c 6c 6f 63 28 4e 55 | 4c 4c 2c 20 73 74 72 6c |alloc(NU|LL, strl|
|000001e0| 65 6e 28 62 75 66 29 2b | 31 29 3b 0d 0a 20 20 20 |en(buf)+|1);.. |
|000001f0| 20 73 74 72 63 70 79 28 | 6d 65 73 73 61 67 65 2c | strcpy(|message,|
|00000200| 20 62 75 66 29 3b 0d 0a | 0d 0a 20 20 20 20 2f 2a | buf);..|.. /*|
|00000210| 20 44 69 73 70 6c 61 79 | 20 74 68 65 20 6d 65 73 | Display| the mes|
|00000220| 73 61 67 65 2e 20 2a 2f | 0d 0a 0d 0a 20 20 20 20 |sage. */|.... |
|00000230| 70 75 74 73 28 6d 65 73 | 73 61 67 65 29 3b 0d 0a |puts(mes|sage);..|
|00000240| 0d 0a 20 20 20 20 2f 2a | 20 47 65 74 20 61 6e 6f |.. /*| Get ano|
|00000250| 74 68 65 72 20 73 74 72 | 69 6e 67 20 66 72 6f 6d |ther str|ing from|
|00000260| 20 74 68 65 20 75 73 65 | 72 2e 20 2a 2f 0d 0a 0d | the use|r. */...|
|00000270| 0a 20 20 20 20 70 75 74 | 73 28 22 45 6e 74 65 72 |. put|s("Enter|
|00000280| 20 61 6e 6f 74 68 65 72 | 20 6c 69 6e 65 20 6f 66 | another| line of|
|00000290| 20 74 65 78 74 2e 22 29 | 3b 0d 0a 20 20 20 20 67 | text.")|;.. g|
|000002a0| 65 74 73 28 62 75 66 29 | 3b 0d 0a 0d 0a 20 20 20 |ets(buf)|;.... |
|000002b0| 20 2f 2a 20 49 6e 63 72 | 65 61 73 65 20 74 68 65 | /* Incr|ease the|
|000002c0| 20 61 6c 6c 6f 63 61 74 | 69 6f 6e 2c 20 74 68 65 | allocat|ion, the|
|000002d0| 6e 20 63 6f 6e 63 61 74 | 65 6e 61 74 65 20 74 68 |n concat|enate th|
|000002e0| 65 20 73 74 72 69 6e 67 | 20 74 6f 20 69 74 2e 20 |e string| to it. |
|000002f0| 2a 2f 0d 0a 0d 0a 20 20 | 20 20 6d 65 73 73 61 67 |*/.... | messag|
|00000300| 65 20 3d 20 72 65 61 6c | 6c 6f 63 28 6d 65 73 73 |e = real|loc(mess|
|00000310| 61 67 65 2c 28 73 74 72 | 6c 65 6e 28 6d 65 73 73 |age,(str|len(mess|
|00000320| 61 67 65 29 20 2b 20 73 | 74 72 6c 65 6e 28 62 75 |age) + s|trlen(bu|
|00000330| 66 29 2b 31 29 29 3b 0d | 0a 20 20 20 20 73 74 72 |f)+1));.|. str|
|00000340| 63 61 74 28 6d 65 73 73 | 61 67 65 2c 20 62 75 66 |cat(mess|age, buf|
|00000350| 29 3b 0d 0a 0d 0a 20 20 | 20 20 2f 2a 20 44 69 73 |);.... | /* Dis|
|00000360| 70 6c 61 79 20 74 68 65 | 20 6e 65 77 20 6d 65 73 |play the| new mes|
|00000370| 73 61 67 65 2e 20 2a 2f | 0d 0a 20 20 20 20 70 75 |sage. */|.. pu|
|00000380| 74 73 28 6d 65 73 73 61 | 67 65 29 3b 0d 0a 20 20 |ts(messa|ge);.. |
|00000390| 20 20 72 65 74 75 72 6e | 20 30 3b 0d 0a 7d 0d 0a | return| 0;..}..|
|000003a0| 0d 0a 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000003f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000400| 00 00 01 00 00 00 01 00 | 00 00 00 00 00 00 00 1e |........|........|
|00000410| 54 68 69 73 20 72 65 73 | 6f 75 72 63 65 20 66 6f |This res|ource fo|
|00000420| 72 6b 20 69 6e 74 65 6e | 74 69 6f 6e 61 6c 6c 79 |rk inten|tionally|
|00000430| 20 6c 65 66 74 20 62 6c | 61 6e 6b 20 20 20 00 00 | left bl|ank ..|
|00000440| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000450| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000460| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000470| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000480| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000490| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000004a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000004b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000004c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000004d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000004e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000004f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000500| 00 00 01 00 00 00 01 00 | 00 00 00 00 00 00 00 1e |........|........|
|00000510| 00 00 00 00 00 00 00 00 | 00 1c 00 1e ff ff 00 00 |........|........|
|00000520| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000530| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000540| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000550| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000560| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000570| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+