Computer Science Canada Strange output |
Author: | jamonathin [ Sun Sep 24, 2006 7:18 pm ] | ||
Post subject: | Strange output | ||
Hey all, I haven't done C in forever and i decided to do a sample problem out of my textbook. I recently got lcc-win32 as my compiler, and just started to use it today. The problem is very simple - You have 2 yards. You have the lengths and widths of the yards and the houses on them, determine the leftover (grass area). Now im probabily doing something wrong in my printf command, but i kept getting a HUGE number for a very small input. And to test it i put the printf result part at the top (where the areas should be 0), yet i still get some some HUGE number . . . wtf mayte?
Example Output wrote: Yard1: 1245036 Yard2: 1245032 |
Author: | md [ Sun Sep 24, 2006 7:24 pm ] |
Post subject: | |
don't pass pointers; just pass the ints |
Author: | Tony [ Sun Sep 24, 2006 8:11 pm ] |
Post subject: | |
yeah, &areaYard1 actually prints the address of the variable, not the value stored there. Notice how your yard1 and yard2 are 4 units appart. Incidently the space reserved for a single integer variable is 4 bytes ![]() |
Author: | jamonathin [ Sun Sep 24, 2006 8:38 pm ] |
Post subject: | |
ooooo, lol thanks ![]() |