apparently in C, chars are 'upcast' in order to be used.
another interesting thing was how a logical and (&&) and or (||) were represented: think of a serial circuit with 2 switches - both switches must be ON in order for the circuit to power the load; for logical 'or', we can picture the 2 switches in parallel along with the load in serial - as long as one is true, or ON, the load is powered.
Wednesday, March 17, 2010
Wednesday, January 27, 2010
Define statements
apparently, define statements (#define) are simply a search and replace. (pre-compiled)
the example used in class was:
#define sum a+b
anywhere in the program where sum is found, its value will be replaced by a+b.
another use of the define statement, would be the use for macros and they are generally preferred to be one liners
i.e.
#define sum(x,y) ((x)+(y))
it is essentially a function; anywhere sum(x,y) is found, the values in found as the parameters will be summed up.
*keep in mind, that when there are '#', that those should be 'compiled' first; there are essentially '2 walkthroughs when looking at a program with precompiled code'
the example used in class was:
#define sum a+b
anywhere in the program where sum is found, its value will be replaced by a+b.
another use of the define statement, would be the use for macros and they are generally preferred to be one liners
i.e.
#define sum(x,y) ((x)+(y))
it is essentially a function; anywhere sum(x,y) is found, the values in found as the parameters will be summed up.
*keep in mind, that when there are '#', that those should be 'compiled' first; there are essentially '2 walkthroughs when looking at a program with precompiled code'
Tuesday, January 12, 2010
Subscribe to:
Posts (Atom)