Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
#else 9 alternati(e
#i$de$ %%linu"
static inline intE0%t
gettime(void) {...}
#eli$ de$ined(sun)
static inline intE0%t
gettime(void) {return (intE0%t)gethrtime()}
#else
static inline intE0%t
gettime(void) {... gettimeo$day()...}
#endi$
Fred Kuhns (
06/27/14)
CSE332 Object Oriented
Pr!r"##in! $"b
,6
Another $imple C Program
int main (int argc, char **argv) {
int i!
print$(F'here are Gd arguments3nH, argc)!
for (i - $# i < argc# i)))
print$(FArg Gd / Gs3nH, i, argv[i])!
return 4!
%
int "[=]!
"[.] is the same as Q(" < .)" the compiler will assume !ou
mean ) oAects e!ond element @.
Arra!s and Pointers
0
1
2
3
4
1 0 2 3
little endian byte ordering
#e#r% &"%ut 'r "rr"% (
Fred Kuhns (
06/27/14)
CSE332 Object Oriented
Pr!r"##in! $"b
,?
Pointers
* For an! t!pe +" !ou ma! form a pointer t!pe to +.
0 Pointers ma! reference a function or an oAect.
0 +he (alue of a pointer is the address of the corresponding oAect or
function
0 %@amples9 int *i! char *"! int (*my$unc)()!
* Pointer operators9 * dereferences a pointer" ; creates a pointer
4reference to5
if (a Q 0 II b L 64) {
c / a * b! b / 4!
print$(Fa / Gd, a32s address / 4"G4R"3nH, a, (uint7.%t)Ia)!
} else {
c / a < b! b / a!
}
* +hese two statements are ePui(alent9