18.08.2013 Views

Dalla A alla Z passando per C - Robotica

Dalla A alla Z passando per C - Robotica

Dalla A alla Z passando per C - Robotica

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.14 Estrazione di un indirizzo<br />

Esempio:<br />

o<strong>per</strong>atore &<br />

sintassi & espr<br />

“e” commerciale<br />

n. o<strong>per</strong>andi ritorna l’indirizzo di espr<br />

utilizzo 1<br />

associativita’ ⇐=<br />

commutativita’ NO<br />

#include <br />

struct stat stbuf;<br />

/* la funzione chiamata scrive in stbuf */<br />

stat("/bin/sh", &stbuf);<br />

char s[32];<br />

/* sscanf converte da stringa e scrive in i */<br />

sscanf(s, "%i", &i);<br />

6.15 Uso di puntatore<br />

o<strong>per</strong>atore *<br />

asterisco<br />

sintassi * ptr<br />

n. o<strong>per</strong>andi dereferenzia il puntatore ptr<br />

utilizzo 1<br />

associativita’ ⇐=<br />

commutativita’ NO<br />

L’o<strong>per</strong>atore <strong>per</strong>mette l’uso del valore contenuto all’indirizzo memorizzato in un puntatore.<br />

int v[32], *p;<br />

for (p = v + 32; p >= v; p--)<br />

sum = sum + *p;<br />

61

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!