home *** CD-ROM | disk | FTP | other *** search
/ Sams Teach Yourself C in 21 Days (6th Edition) / STYC216E.ISO / mac / Examples / Day22 / square.cpp < prev   
MacBinary  |  2002-05-23  |  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
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, Thu May 23 23:13:36 2002, modified Thu May 23 23:13:36 2002, creator 'LMAN', type ASCII, 1336 bytes "square.cpp" , at 0x5b8 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 0a 73 71 75 61 72 65 | 2e 63 70 70 00 00 00 00 |..square|.cpp....|
|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 38 00 | 00 01 1e b9 13 60 60 b9 |......8.|.....``.|
|00000060| 13 60 60 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 bc 83 00 00 |........|........|
|00000080| 2f 2a 20 41 20 43 20 6c | 69 73 74 69 6e 67 20 77 |/* A C l|isting w|
|00000090| 69 74 68 20 73 6f 6d 65 | 74 68 69 6e 67 20 6f 64 |ith some|thing od|
|000000a0| 64 20 2d 20 20 2a 2f 0d | 0a 2f 2a 20 20 20 75 73 |d - */.|./* us|
|000000b0| 69 6e 67 20 61 20 73 71 | 75 61 72 65 28 29 20 66 |ing a sq|uare() f|
|000000c0| 75 6e 63 74 69 6f 6e 20 | 74 77 69 63 65 20 2a 2f |unction |twice */|
|000000d0| 0d 0a 23 69 6e 63 6c 75 | 64 65 20 3c 73 74 64 69 |..#inclu|de <stdi|
|000000e0| 6f 2e 68 3e 0d 0a 23 69 | 6e 63 6c 75 64 65 20 3c |o.h>..#i|nclude <|
|000000f0| 73 74 64 6c 69 62 2e 68 | 3e 0d 0a 0d 0a 2f 2a 73 |stdlib.h|>..../*s|
|00000100| 71 75 61 72 65 20 66 75 | 6e 63 74 69 6f 6e 20 2d |quare fu|nction -|
|00000110| 20 74 68 65 20 66 69 72 | 73 74 20 6f 6e 65 21 2a | the fir|st one!*|
|00000120| 2f 0d 0a 76 6f 69 64 20 | 73 71 75 61 72 65 28 20 |/..void |square( |
|00000130| 69 6e 74 20 74 6f 70 6c | 65 66 74 58 2c 20 69 6e |int topl|eftX, in|
|00000140| 74 20 74 6f 70 6c 65 66 | 74 59 2c 20 6c 6f 6e 67 |t toplef|tY, long|
|00000150| 20 77 69 64 74 68 20 29 | 0d 0a 7b 0d 0a 20 20 20 | width )|..{.. |
|00000160| 20 69 6e 74 20 78 63 74 | 72 20 3d 20 30 3b 0d 0a | int xct|r = 0;..|
|00000170| 20 20 20 20 69 6e 74 20 | 79 63 74 72 20 3d 20 30 | int |yctr = 0|
|00000180| 3b 0d 0a 20 20 20 20 2f | 2a 20 54 68 69 73 20 6c |;.. /|* This l|
|00000190| 69 73 74 69 6e 67 20 61 | 73 73 75 6d 65 73 20 62 |isting a|ssumes b|
|000001a0| 6f 74 74 6f 6d 20 76 61 | 6c 75 65 73 20 61 72 65 |ottom va|lues are|
|000001b0| 20 67 72 65 61 74 65 72 | 20 74 68 61 6e 20 74 6f | greater| than to|
|000001c0| 70 20 76 61 6c 75 65 73 | 2a 2f 0d 0a 0d 0a 20 20 |p values|*/.... |
|000001d0| 20 20 66 6f 72 20 28 20 | 78 63 74 72 20 3d 20 30 | for ( |xctr = 0|
|000001e0| 3b 20 78 63 74 72 20 3c | 20 77 69 64 74 68 3b 20 |; xctr <| width; |
|000001f0| 78 63 74 72 2b 2b 29 0d | 0a 20 20 20 20 7b 0d 0a |xctr++).|. {..|
|00000200| 20 20 20 20 20 20 20 20 | 70 72 69 6e 74 66 28 22 | |printf("|
|00000210| 5c 6e 22 29 3b 0d 0a 0d | 0a 20 20 20 20 20 20 20 |\n");...|. |
|00000220| 20 66 6f 72 20 28 20 79 | 63 74 72 20 3d 20 30 3b | for ( y|ctr = 0;|
|00000230| 20 79 63 74 72 20 3c 20 | 77 69 64 74 68 3b 20 79 | yctr < |width; y|
|00000240| 63 74 72 2b 2b 20 29 0d | 0a 20 20 20 20 20 20 20 |ctr++ ).|. |
|00000250| 20 7b 0d 0a 20 20 20 20 | 20 20 20 20 20 20 20 20 | {.. | |
|00000260| 70 72 69 6e 74 66 28 22 | 2a 22 29 3b 0d 0a 20 20 |printf("|*");.. |
|00000270| 20 20 20 20 20 20 7d 0d | 0a 20 20 20 20 7d 0d 0a | }.|. }..|
|00000280| 7d 0d 0a 0d 0a 2f 2a 73 | 71 75 61 72 65 20 66 75 |}..../*s|quare fu|
|00000290| 6e 63 74 69 6f 6e 20 2d | 20 74 68 65 20 73 65 63 |nction -| the sec|
|000002a0| 6f 6e 64 20 6f 6e 65 21 | 20 2a 2f 0d 0a 76 6f 69 |ond one!| */..voi|
|000002b0| 64 20 73 71 75 61 72 65 | 28 20 69 6e 74 20 74 6f |d square|( int to|
|000002c0| 70 6c 65 66 74 58 2c 20 | 69 6e 74 20 74 6f 70 6c |pleftX, |int topl|
|000002d0| 65 66 74 59 2c 20 69 6e | 74 20 62 6f 74 74 6f 6d |eftY, in|t bottom|
|000002e0| 6c 65 66 74 58 2c 20 69 | 6e 74 20 62 6f 74 74 6f |leftX, i|nt botto|
|000002f0| 6d 6c 65 66 74 59 29 0d | 0a 7b 0d 0a 20 20 20 20 |mleftY).|.{.. |
|00000300| 69 6e 74 20 78 63 74 72 | 20 3d 20 30 3b 0d 0a 20 |int xctr| = 0;.. |
|00000310| 20 20 20 69 6e 74 20 79 | 63 74 72 20 3d 20 30 3b | int y|ctr = 0;|
|00000320| 0d 0a 0d 0a 20 20 20 20 | 2f 2f 20 54 68 69 73 20 |.... |// This |
|00000330| 6c 69 73 74 69 6e 67 20 | 61 73 73 75 6d 65 73 20 |listing |assumes |
|00000340| 62 6f 74 74 6f 6d 20 76 | 61 6c 75 65 73 20 61 72 |bottom v|alues ar|
|00000350| 65 20 67 72 65 61 74 65 | 72 20 74 68 61 6e 20 74 |e greate|r than t|
|00000360| 6f 70 20 76 61 6c 75 65 | 73 0d 0a 0d 0a 20 20 20 |op value|s.... |
|00000370| 20 66 6f 72 20 28 20 78 | 63 74 72 20 3d 20 30 3b | for ( x|ctr = 0;|
|00000380| 20 78 63 74 72 20 3c 20 | 62 6f 74 74 6f 6d 6c 65 | xctr < |bottomle|
|00000390| 66 74 58 20 2d 20 74 6f | 70 6c 65 66 74 58 3b 20 |ftX - to|pleftX; |
|000003a0| 78 63 74 72 2b 2b 29 0d | 0a 20 20 20 20 7b 0d 0a |xctr++).|. {..|
|000003b0| 20 20 20 20 20 20 20 20 | 70 72 69 6e 74 66 28 22 | |printf("|
|000003c0| 5c 6e 22 29 3b 0d 0a 0d | 0a 20 20 20 20 20 20 20 |\n");...|. |
|000003d0| 20 66 6f 72 20 28 20 79 | 63 74 72 20 3d 20 30 3b | for ( y|ctr = 0;|
|000003e0| 20 79 63 74 72 20 3c 20 | 62 6f 74 74 6f 6d 6c 65 | yctr < |bottomle|
|000003f0| 66 74 59 20 2d 20 74 6f | 70 6c 65 66 74 59 3b 20 |ftY - to|pleftY; |
|00000400| 79 63 74 72 2b 2b 20 29 | 0d 0a 20 20 20 20 20 20 |yctr++ )|.. |
|00000410| 20 20 7b 0d 0a 20 20 20 | 20 20 20 20 20 20 20 20 | {.. | |
|00000420| 20 70 72 69 6e 74 66 28 | 22 2a 22 29 3b 0d 0a 20 | printf(|"*");.. |
|00000430| 20 20 20 20 20 20 20 7d | 0d 0a 20 20 20 20 7d 0d | }|.. }.|
|00000440| 0a 7d 0d 0a 0d 0a 69 6e | 74 20 6d 61 69 6e 28 69 |.}....in|t main(i|
|00000450| 6e 74 20 61 72 67 63 2c | 20 63 68 61 72 2a 20 61 |nt argc,| char* a|
|00000460| 72 67 76 5b 5d 29 0d 0a | 7b 0d 0a 20 20 20 20 69 |rgv[])..|{.. i|
|00000470| 6e 74 20 20 20 70 74 5f | 78 31 20 3d 20 30 2c 20 |nt pt_|x1 = 0, |
|00000480| 70 74 5f 79 31 20 3d 20 | 30 3b 0d 0a 20 20 20 20 |pt_y1 = |0;.. |
|00000490| 69 6e 74 20 20 20 70 74 | 5f 78 32 20 3d 20 35 2c |int pt|_x2 = 5,|
|000004a0| 20 70 74 5f 79 32 20 3d | 20 35 3b 0d 0a 20 20 20 | pt_y2 =| 5;.. |
|000004b0| 20 69 6e 74 20 20 20 70 | 74 5f 78 33 20 3d 20 30 | int p|t_x3 = 0|
|000004c0| 2c 20 70 74 5f 79 33 20 | 3d 20 30 3b 0d 0a 20 20 |, pt_y3 |= 0;.. |
|000004d0| 20 20 6c 6f 6e 67 20 20 | 73 69 64 65 20 3d 20 34 | long |side = 4|
|000004e0| 3b 0d 0a 0d 0a 20 20 20 | 20 2f 2f 20 43 61 6c 6c |;.... | // Call|
|000004f0| 20 74 68 65 20 73 71 75 | 61 72 65 20 66 75 6e 63 | the squ|are func|
|00000500| 74 69 6f 6e 20 74 77 6f | 20 64 69 66 66 65 72 65 |tion two| differe|
|00000510| 6e 74 20 77 61 79 73 0d | 0a 20 20 20 20 73 71 75 |nt ways.|. squ|
|00000520| 61 72 65 28 20 70 74 5f | 78 31 2c 20 70 74 5f 79 |are( pt_|x1, pt_y|
|00000530| 31 2c 20 70 74 5f 78 32 | 2c 20 70 74 5f 79 32 29 |1, pt_x2|, pt_y2)|
|00000540| 3b 0d 0a 0d 0a 20 20 20 | 20 70 72 69 6e 74 66 28 |;.... | printf(|
|00000550| 22 5c 6e 5c 6e 22 29 3b | 20 20 20 2f 2f 70 75 74 |"\n\n");| //put|
|00000560| 20 62 6c 61 6e 6b 20 6c | 69 6e 65 73 20 62 65 74 | blank l|ines bet|
|00000570| 77 65 65 6e 20 73 71 75 | 61 72 65 73 0d 0a 0d 0a |ween squ|ares....|
|00000580| 20 20 20 20 73 71 75 61 | 72 65 28 20 70 74 5f 78 | squa|re( pt_x|
|00000590| 33 2c 20 70 74 5f 79 33 | 2c 20 73 69 64 65 29 3b |3, pt_y3|, side);|
|000005a0| 0d 0a 0d 0a 20 20 20 20 | 72 65 74 75 72 6e 20 30 |.... |return 0|
|000005b0| 3b 0d 0a 7d 0d 0a 0d 0a | 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 |........|........|
+--------+-------------------------+-------------------------+--------+--------+