home *** CD-ROM | disk | FTP | other *** search
/ Sams Teach Yourself C in 21 Days (6th Edition) / STYC216E.ISO / mac / Examples / Day14 / scanf.c < prev    next >
MacBinary  |  2002-05-05  |  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 5 19:55:36 2002, modified Sun May 5 19:55:36 2002, creator 'LMAN', type ASCII, 1359 bytes "scanf.c" , at 0x5cf 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 07 73 63 61 6e 66 2e | 63 00 00 00 00 00 00 00 |..scanf.|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 4f 00 | 00 01 1e b8 fb 76 f8 b8 |......O.|.....v..|
|00000060| fb 76 f8 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.v......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 e7 70 00 00 |........|.....p..|
|00000080| 2f 2a 20 44 65 6d 6f 6e | 73 74 72 61 74 65 73 20 |/* Demon|strates |
|00000090| 73 6f 6d 65 20 75 73 65 | 73 20 6f 66 20 73 63 61 |some use|s of sca|
|000000a0| 6e 66 28 29 2e 20 2a 2f | 0d 0a 0d 0a 23 69 6e 63 |nf(). */|....#inc|
|000000b0| 6c 75 64 65 20 3c 73 74 | 64 69 6f 2e 68 3e 0d 0a |lude <st|dio.h>..|
|000000c0| 0d 0a 0d 0a 0d 0a 69 6e | 74 20 6d 61 69 6e 28 20 |......in|t main( |
|000000d0| 76 6f 69 64 20 29 0d 0a | 7b 0d 0a 20 20 20 20 69 |void )..|{.. i|
|000000e0| 6e 74 20 69 31 3b 0d 0a | 20 20 20 20 69 6e 74 20 |nt i1;..| int |
|000000f0| 69 32 3b 0d 0a 20 20 20 | 20 6c 6f 6e 67 20 6c 31 |i2;.. | long l1|
|00000100| 3b 0d 0a 0d 0a 20 20 20 | 20 64 6f 75 62 6c 65 20 |;.... | double |
|00000110| 64 31 3b 0d 0a 20 20 20 | 20 63 68 61 72 20 62 75 |d1;.. | char bu|
|00000120| 66 31 5b 38 30 5d 3b 0d | 0a 20 20 20 20 63 68 61 |f1[80];.|. cha|
|00000130| 72 20 62 75 66 32 5b 38 | 30 5d 3b 0d 0a 0d 0a 20 |r buf2[8|0];.... |
|00000140| 20 20 20 2f 2a 20 55 73 | 69 6e 67 20 74 68 65 20 | /* Us|ing the |
|00000150| 6c 20 6d 6f 64 69 66 69 | 65 72 20 74 6f 20 65 6e |l modifi|er to en|
|00000160| 74 65 72 20 6c 6f 6e 67 | 20 69 6e 74 65 67 65 72 |ter long| integer|
|00000170| 73 20 61 6e 64 20 64 6f | 75 62 6c 65 73 2e 2a 2f |s and do|ubles.*/|
|00000180| 0d 0a 0d 0a 20 20 20 20 | 70 75 74 73 28 22 45 6e |.... |puts("En|
|00000190| 74 65 72 20 61 6e 20 69 | 6e 74 65 67 65 72 20 61 |ter an i|nteger a|
|000001a0| 6e 64 20 61 20 66 6c 6f | 61 74 69 6e 67 20 70 6f |nd a flo|ating po|
|000001b0| 69 6e 74 20 6e 75 6d 62 | 65 72 2e 22 29 3b 0d 0a |int numb|er.");..|
|000001c0| 20 20 20 20 73 63 61 6e | 66 28 22 25 6c 64 20 25 | scan|f("%ld %|
|000001d0| 6c 66 22 2c 20 26 6c 31 | 2c 20 26 64 31 29 3b 0d |lf", &l1|, &d1);.|
|000001e0| 0a 20 20 20 20 70 72 69 | 6e 74 66 28 22 5c 6e 59 |. pri|ntf("\nY|
|000001f0| 6f 75 20 65 6e 74 65 72 | 65 64 20 25 6c 64 20 61 |ou enter|ed %ld a|
|00000200| 6e 64 20 25 6c 66 2e 5c | 6e 22 2c 6c 31 2c 20 64 |nd %lf.\|n",l1, d|
|00000210| 31 29 3b 0d 0a 20 20 20 | 20 70 75 74 73 28 22 54 |1);.. | puts("T|
|00000220| 68 65 20 73 63 61 6e 66 | 28 29 20 66 6f 72 6d 61 |he scanf|() forma|
|00000230| 74 20 73 74 72 69 6e 67 | 20 75 73 65 64 20 74 68 |t string| used th|
|00000240| 65 20 6c 20 6d 6f 64 69 | 66 69 65 72 20 74 6f 20 |e l modi|fier to |
|00000250| 73 74 6f 72 65 22 29 3b | 0d 0a 20 20 20 20 70 75 |store");|.. pu|
|00000260| 74 73 28 22 79 6f 75 72 | 20 69 6e 70 75 74 20 69 |ts("your| input i|
|00000270| 6e 20 61 20 74 79 70 65 | 20 6c 6f 6e 67 20 61 6e |n a type| long an|
|00000280| 64 20 61 20 74 79 70 65 | 20 64 6f 75 62 6c 65 2e |d a type| double.|
|00000290| 5c 6e 22 29 3b 0d 0a 0d | 0a 20 20 20 20 66 66 6c |\n");...|. ffl|
|000002a0| 75 73 68 28 73 74 64 69 | 6e 29 3b 0d 0a 0d 0a 20 |ush(stdi|n);.... |
|000002b0| 20 20 20 2f 2a 20 55 73 | 65 20 66 69 65 6c 64 20 | /* Us|e field |
|000002c0| 77 69 64 74 68 20 74 6f | 20 73 70 6c 69 74 20 69 |width to| split i|
|000002d0| 6e 70 75 74 2e 20 2a 2f | 0d 0a 0d 0a 20 20 20 20 |nput. */|.... |
|000002e0| 70 75 74 73 28 22 45 6e | 74 65 72 20 61 20 35 20 |puts("En|ter a 5 |
|000002f0| 64 69 67 69 74 20 69 6e | 74 65 67 65 72 20 28 66 |digit in|teger (f|
|00000300| 6f 72 20 65 78 61 6d 70 | 6c 65 2c 20 35 34 33 32 |or examp|le, 5432|
|00000310| 31 29 2e 22 29 3b 0d 0a | 20 20 20 20 73 63 61 6e |1).");..| scan|
|00000320| 66 28 22 25 32 64 25 33 | 64 22 2c 20 26 69 31 2c |f("%2d%3|d", &i1,|
|00000330| 20 26 69 32 29 3b 0d 0a | 0d 0a 20 20 20 20 70 72 | &i2);..|.. pr|
|00000340| 69 6e 74 66 28 22 5c 6e | 59 6f 75 20 65 6e 74 65 |intf("\n|You ente|
|00000350| 72 65 64 20 25 64 20 61 | 6e 64 20 25 64 2e 5c 6e |red %d a|nd %d.\n|
|00000360| 22 2c 20 69 31 2c 20 69 | 32 29 3b 0d 0a 20 20 20 |", i1, i|2);.. |
|00000370| 20 70 75 74 73 28 22 4e | 6f 74 65 20 68 6f 77 20 | puts("N|ote how |
|00000380| 74 68 65 20 66 69 65 6c | 64 20 77 69 64 74 68 20 |the fiel|d width |
|00000390| 73 70 65 63 69 66 69 65 | 72 20 69 6e 20 74 68 65 |specifie|r in the|
|000003a0| 20 73 63 61 6e 66 28 29 | 20 66 6f 72 6d 61 74 22 | scanf()| format"|
|000003b0| 29 3b 0d 0a 20 20 20 20 | 70 75 74 73 28 22 73 74 |);.. |puts("st|
|000003c0| 72 69 6e 67 20 73 70 6c | 69 74 20 79 6f 75 72 20 |ring spl|it your |
|000003d0| 69 6e 70 75 74 20 69 6e | 74 6f 20 74 77 6f 20 76 |input in|to two v|
|000003e0| 61 6c 75 65 73 2e 5c 6e | 22 29 3b 0d 0a 0d 0a 20 |alues.\n|");.... |
|000003f0| 20 20 20 66 66 6c 75 73 | 68 28 73 74 64 69 6e 29 | fflus|h(stdin)|
|00000400| 3b 0d 0a 0d 0a 20 20 20 | 20 2f 2a 20 55 73 69 6e |;.... | /* Usin|
|00000410| 67 20 61 6e 20 65 78 63 | 6c 75 64 65 64 20 73 70 |g an exc|luded sp|
|00000420| 61 63 65 20 74 6f 20 73 | 70 6c 69 74 20 61 20 6c |ace to s|plit a l|
|00000430| 69 6e 65 20 6f 66 20 69 | 6e 70 75 74 20 69 6e 74 |ine of i|nput int|
|00000440| 6f 20 2a 2f 0d 0a 20 20 | 20 20 2f 2a 20 74 77 6f |o */.. | /* two|
|00000450| 20 73 74 72 69 6e 67 73 | 20 61 74 20 74 68 65 20 | strings| at the |
|00000460| 73 70 61 63 65 2e 20 2a | 2f 0d 0a 0d 0a 20 20 20 |space. *|/.... |
|00000470| 20 70 75 74 73 28 22 45 | 6e 74 65 72 20 79 6f 75 | puts("E|nter you|
|00000480| 72 20 66 69 72 73 74 20 | 61 6e 64 20 6c 61 73 74 |r first |and last|
|00000490| 20 6e 61 6d 65 73 20 73 | 65 70 61 72 61 74 65 64 | names s|eparated|
|000004a0| 20 62 79 20 61 20 73 70 | 61 63 65 2e 22 29 3b 0d | by a sp|ace.");.|
|000004b0| 0a 20 20 20 20 73 63 61 | 6e 66 28 22 25 5b 5e 20 |. sca|nf("%[^ |
|000004c0| 5d 25 73 22 2c 20 62 75 | 66 31 2c 20 62 75 66 32 |]%s", bu|f1, buf2|
|000004d0| 29 3b 0d 0a 20 20 20 20 | 70 72 69 6e 74 66 28 22 |);.. |printf("|
|000004e0| 5c 6e 59 6f 75 72 20 66 | 69 72 73 74 20 6e 61 6d |\nYour f|irst nam|
|000004f0| 65 20 69 73 20 25 73 5c | 6e 22 2c 20 62 75 66 31 |e is %s\|n", buf1|
|00000500| 29 3b 0d 0a 20 20 20 20 | 70 72 69 6e 74 66 28 22 |);.. |printf("|
|00000510| 59 6f 75 72 20 6c 61 73 | 74 20 6e 61 6d 65 20 69 |Your las|t name i|
|00000520| 73 20 25 73 5c 6e 22 2c | 20 62 75 66 32 29 3b 0d |s %s\n",| buf2);.|
|00000530| 0a 20 20 20 20 70 75 74 | 73 28 22 4e 6f 74 65 20 |. put|s("Note |
|00000540| 68 6f 77 20 5b 5e 20 5d | 20 69 6e 20 74 68 65 20 |how [^ ]| in the |
|00000550| 73 63 61 6e 66 28 29 20 | 66 6f 72 6d 61 74 20 73 |scanf() |format s|
|00000560| 74 72 69 6e 67 2c 20 62 | 79 20 65 78 63 6c 75 64 |tring, b|y exclud|
|00000570| 69 6e 67 22 29 3b 0d 0a | 20 20 20 20 70 75 74 73 |ing");..| puts|
|00000580| 28 22 74 68 65 20 73 70 | 61 63 65 20 63 68 61 72 |("the sp|ace char|
|00000590| 61 63 74 65 72 2c 20 63 | 61 75 73 65 64 20 74 68 |acter, c|aused th|
|000005a0| 65 20 69 6e 70 75 74 20 | 74 6f 20 62 65 20 73 70 |e input |to be sp|
|000005b0| 6c 69 74 2e 22 29 3b 0d | 0a 0d 0a 20 20 20 20 72 |lit.");.|... r|
|000005c0| 65 74 75 72 6e 20 30 3b | 0d 0a 7d 0d 0a 0d 0a 00 |eturn 0;|..}.....|
|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 |........|........|
+--------+-------------------------+-------------------------+--------+--------+