home *** CD-ROM | disk | FTP | other *** search
/ Sams Teach Yourself C in 21 Days (6th Edition) / STYC216E.ISO / mac / Examples / Day16 / copyit.c next >
MacBinary  |  2002-05-12  |  1.9 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 May 12 19:21:32 2002, modified Sun May 12 19:21:32 2002, creator 'LMAN', type ASCII, 1296 bytes "copyit.c" , at 0x590 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 08 63 6f 70 79 69 74 | 2e 63 00 00 00 00 00 00 |..copyit|.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 05 10 00 | 00 01 1e b9 04 a9 7c b9 |........|......|.|
|00000060| 04 a9 7c 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |..|.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 28 ed 00 00 |........|....(...|
|00000080| 2f 2a 20 43 6f 70 79 69 | 6e 67 20 61 20 66 69 6c |/* Copyi|ng a fil|
|00000090| 65 2e 20 2a 2f 0d 0a 0d | 0a 23 69 6e 63 6c 75 64 |e. */...|.#includ|
|000000a0| 65 20 3c 73 74 64 69 6f | 2e 68 3e 0d 0a 0d 0a 69 |e <stdio|.h>....i|
|000000b0| 6e 74 20 66 69 6c 65 5f | 63 6f 70 79 28 20 63 68 |nt file_|copy( ch|
|000000c0| 61 72 20 2a 6f 6c 64 6e | 61 6d 65 2c 20 63 68 61 |ar *oldn|ame, cha|
|000000d0| 72 20 2a 6e 65 77 6e 61 | 6d 65 20 29 3b 0d 0a 0d |r *newna|me );...|
|000000e0| 0a 69 6e 74 20 6d 61 69 | 6e 28 20 76 6f 69 64 20 |.int mai|n( void |
|000000f0| 29 0d 0a 7b 0d 0a 20 20 | 20 20 63 68 61 72 20 73 |)..{.. | char s|
|00000100| 6f 75 72 63 65 5b 38 30 | 5d 2c 20 64 65 73 74 69 |ource[80|], desti|
|00000110| 6e 61 74 69 6f 6e 5b 38 | 30 5d 3b 0d 0a 0d 0a 20 |nation[8|0];.... |
|00000120| 20 20 20 2f 2a 20 47 65 | 74 20 74 68 65 20 73 6f | /* Ge|t the so|
|00000130| 75 72 63 65 20 61 6e 64 | 20 64 65 73 74 69 6e 61 |urce and| destina|
|00000140| 74 69 6f 6e 20 6e 61 6d | 65 73 2e 20 2a 2f 0d 0a |tion nam|es. */..|
|00000150| 0d 0a 20 20 20 20 70 72 | 69 6e 74 66 28 22 5c 6e |.. pr|intf("\n|
|00000160| 45 6e 74 65 72 20 73 6f | 75 72 63 65 20 66 69 6c |Enter so|urce fil|
|00000170| 65 3a 20 22 29 3b 0d 0a | 20 20 20 20 67 65 74 73 |e: ");..| gets|
|00000180| 28 73 6f 75 72 63 65 29 | 3b 0d 0a 20 20 20 20 70 |(source)|;.. p|
|00000190| 72 69 6e 74 66 28 22 5c | 6e 45 6e 74 65 72 20 64 |rintf("\|nEnter d|
|000001a0| 65 73 74 69 6e 61 74 69 | 6f 6e 20 66 69 6c 65 3a |estinati|on file:|
|000001b0| 20 22 29 3b 0d 0a 20 20 | 20 20 67 65 74 73 28 64 | ");.. | gets(d|
|000001c0| 65 73 74 69 6e 61 74 69 | 6f 6e 29 3b 0d 0a 0d 0a |estinati|on);....|
|000001d0| 20 20 20 20 69 66 20 28 | 20 66 69 6c 65 5f 63 6f | if (| file_co|
|000001e0| 70 79 28 20 73 6f 75 72 | 63 65 2c 20 64 65 73 74 |py( sour|ce, dest|
|000001f0| 69 6e 61 74 69 6f 6e 20 | 29 20 3d 3d 20 30 20 29 |ination |) == 0 )|
|00000200| 0d 0a 20 20 20 20 20 20 | 20 20 70 75 74 73 28 22 |.. | puts("|
|00000210| 43 6f 70 79 20 6f 70 65 | 72 61 74 69 6f 6e 20 73 |Copy ope|ration s|
|00000220| 75 63 63 65 73 73 66 75 | 6c 22 29 3b 0d 0a 20 20 |uccessfu|l");.. |
|00000230| 20 20 65 6c 73 65 0d 0a | 20 20 20 20 20 20 20 20 | else..| |
|00000240| 66 70 72 69 6e 74 66 28 | 73 74 64 65 72 72 2c 20 |fprintf(|stderr, |
|00000250| 22 45 72 72 6f 72 20 64 | 75 72 69 6e 67 20 63 6f |"Error d|uring co|
|00000260| 70 79 20 6f 70 65 72 61 | 74 69 6f 6e 22 29 3b 0d |py opera|tion");.|
|00000270| 0a 20 20 20 20 72 65 74 | 75 72 6e 28 30 29 3b 0d |. ret|urn(0);.|
|00000280| 0a 7d 0d 0a 69 6e 74 20 | 66 69 6c 65 5f 63 6f 70 |.}..int |file_cop|
|00000290| 79 28 20 63 68 61 72 20 | 2a 6f 6c 64 6e 61 6d 65 |y( char |*oldname|
|000002a0| 2c 20 63 68 61 72 20 2a | 6e 65 77 6e 61 6d 65 20 |, char *|newname |
|000002b0| 29 0d 0a 7b 0d 0a 20 20 | 20 20 46 49 4c 45 20 2a |)..{.. | FILE *|
|000002c0| 66 6f 6c 64 2c 20 2a 66 | 6e 65 77 3b 0d 0a 20 20 |fold, *f|new;.. |
|000002d0| 20 20 69 6e 74 20 63 3b | 0d 0a 0d 0a 20 20 20 20 | int c;|.... |
|000002e0| 2f 2a 20 4f 70 65 6e 20 | 74 68 65 20 73 6f 75 72 |/* Open |the sour|
|000002f0| 63 65 20 66 69 6c 65 20 | 66 6f 72 20 72 65 61 64 |ce file |for read|
|00000300| 69 6e 67 20 69 6e 20 62 | 69 6e 61 72 79 20 6d 6f |ing in b|inary mo|
|00000310| 64 65 2e 20 2a 2f 0d 0a | 0d 0a 20 20 20 20 69 66 |de. */..|.. if|
|00000320| 20 28 20 28 20 66 6f 6c | 64 20 3d 20 66 6f 70 65 | ( ( fol|d = fope|
|00000330| 6e 28 20 6f 6c 64 6e 61 | 6d 65 2c 20 22 72 62 22 |n( oldna|me, "rb"|
|00000340| 20 29 20 29 20 3d 3d 20 | 4e 55 4c 4c 20 29 0d 0a | ) ) == |NULL )..|
|00000350| 20 20 20 20 20 20 20 20 | 72 65 74 75 72 6e 20 2d | |return -|
|00000360| 31 3b 0d 0a 0d 0a 20 20 | 20 20 2f 2a 20 4f 70 65 |1;.... | /* Ope|
|00000370| 6e 20 74 68 65 20 64 65 | 73 74 69 6e 61 74 69 6f |n the de|stinatio|
|00000380| 6e 20 66 69 6c 65 20 66 | 6f 72 20 77 72 69 74 69 |n file f|or writi|
|00000390| 6e 67 20 69 6e 20 62 69 | 6e 61 72 79 20 6d 6f 64 |ng in bi|nary mod|
|000003a0| 65 2e 20 2a 2f 0d 0a 0d | 0a 20 20 20 20 69 66 20 |e. */...|. if |
|000003b0| 28 20 28 20 66 6e 65 77 | 20 3d 20 66 6f 70 65 6e |( ( fnew| = fopen|
|000003c0| 28 20 6e 65 77 6e 61 6d | 65 2c 20 22 77 62 22 20 |( newnam|e, "wb" |
|000003d0| 29 20 29 20 3d 3d 20 4e | 55 4c 4c 20 20 29 0d 0a |) ) == N|ULL )..|
|000003e0| 20 20 20 20 7b 0d 0a 20 | 20 20 20 20 20 20 20 66 | {.. | f|
|000003f0| 63 6c 6f 73 65 20 28 20 | 66 6f 6c 64 20 29 3b 0d |close ( |fold );.|
|00000400| 0a 20 20 20 20 20 20 20 | 20 72 65 74 75 72 6e 20 |. | return |
|00000410| 2d 31 3b 0d 0a 20 20 20 | 20 7d 0d 0a 0d 0a 20 20 |-1;.. | }.... |
|00000420| 20 20 2f 2a 20 52 65 61 | 64 20 6f 6e 65 20 62 79 | /* Rea|d one by|
|00000430| 74 65 20 61 74 20 61 20 | 74 69 6d 65 20 66 72 6f |te at a |time fro|
|00000440| 6d 20 74 68 65 20 73 6f | 75 72 63 65 3b 20 69 66 |m the so|urce; if|
|00000450| 20 65 6e 64 20 6f 66 20 | 66 69 6c 65 20 2a 2f 0d | end of |file */.|
|00000460| 0a 20 20 20 20 2f 2a 20 | 68 61 73 20 6e 6f 74 20 |. /* |has not |
|00000470| 62 65 65 6e 20 72 65 61 | 63 68 65 64 2c 20 77 72 |been rea|ched, wr|
|00000480| 69 74 65 20 74 68 65 20 | 62 79 74 65 20 74 6f 20 |ite the |byte to |
|00000490| 74 68 65 20 2a 2f 0d 0a | 20 20 20 20 2f 2a 20 64 |the */..| /* d|
|000004a0| 65 73 74 69 6e 61 74 69 | 6f 6e 2e 20 2a 2f 0d 0a |estinati|on. */..|
|000004b0| 0d 0a 20 20 20 20 77 68 | 69 6c 65 20 28 31 29 0d |.. wh|ile (1).|
|000004c0| 0a 20 20 20 20 7b 0d 0a | 20 20 20 20 20 20 20 20 |. {..| |
|000004d0| 63 20 3d 20 66 67 65 74 | 63 28 20 66 6f 6c 64 20 |c = fget|c( fold |
|000004e0| 29 3b 0d 0a 0d 0a 20 20 | 20 20 20 20 20 20 69 66 |);.... | if|
|000004f0| 20 28 20 21 66 65 6f 66 | 28 20 66 6f 6c 64 20 29 | ( !feof|( fold )|
|00000500| 20 29 0d 0a 20 20 20 20 | 20 20 20 20 20 20 20 20 | ).. | |
|00000510| 66 70 75 74 63 28 20 63 | 2c 20 66 6e 65 77 20 29 |fputc( c|, fnew )|
|00000520| 3b 0d 0a 20 20 20 20 20 | 20 20 20 65 6c 73 65 0d |;.. | else.|
|00000530| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 62 72 65 |. | bre|
|00000540| 61 6b 3b 0d 0a 20 20 20 | 20 7d 0d 0a 0d 0a 20 20 |ak;.. | }.... |
|00000550| 20 20 66 63 6c 6f 73 65 | 20 28 20 66 6e 65 77 20 | fclose| ( fnew |
|00000560| 29 3b 0d 0a 20 20 20 20 | 66 63 6c 6f 73 65 20 28 |);.. |fclose (|
|00000570| 20 66 6f 6c 64 20 29 3b | 0d 0a 0d 0a 20 20 20 20 | fold );|.... |
|00000580| 72 65 74 75 72 6e 20 30 | 3b 0d 0a 7d 0d 0a 0d 0a |return 0|;..}....|
|00000590| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000600| 00 00 01 00 00 00 01 00 | 00 00 00 00 00 00 00 1e |........|........|
|00000610| 54 68 69 73 20 72 65 73 | 6f 75 72 63 65 20 66 6f |This res|ource fo|
|00000620| 72 6b 20 69 6e 74 65 6e | 74 69 6f 6e 61 6c 6c 79 |rk inten|tionally|
|00000630| 20 6c 65 66 74 20 62 6c | 61 6e 6b 20 20 20 00 00 | left bl|ank ..|
|00000640| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000650| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000660| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000670| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000680| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000690| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000006a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000006b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000006c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000006d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000006e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000006f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000700| 00 00 01 00 00 00 01 00 | 00 00 00 00 00 00 00 1e |........|........|
|00000710| 00 00 00 00 00 00 00 00 | 00 1c 00 1e ff ff 00 00 |........|........|
|00000720| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000730| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000740| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000750| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000760| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000770| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+