-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
gm********@gmail.com wrote:
Hi all,
I'm teaching myself C, and I've come upon syntax in a program (Ping)
that I don't understand. For instance, we have
struct sockaddr_in *to = (struct sockaddr_in *) &whereto;
and then
bzero((char *)&whereto, sizeof(struct sockaddr) );
And all throughout we have stars within parenthese like (char *) and
(struct wawa *). What do these mean?
These expressions force a type conversion to the type named within the
parentheses.
In your example
struct sockaddr_in *to = (struct sockaddr_in *) &whereto;
whereto is presumably defined as something other than a struct
sockaddr_in.
The (struct sockaddr_in *) coerces &whereto to be interpreted as a
pointer to a struct sockaddr_in.
>It must be something about a
pointer,
In your examples it is. However, in the general case, type coersion can
be used on any type, not just pointers. Such coersion is often
unnecessary, and (as it is dangerous) should be used with caution.
but I haven't been able to find this anywhere in the books I
have, but then, I'm not quite sure how I would find it even if it's
there. Thx.
HTH
- --
Lew Pitcher
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32) - WinPT 0.11.12
iD8DBQFFE/pdagVFX4UWr64RAm0rAKDV2AyR6E3A2tOBQ6mt3IF/1som7QCeO9Uk
V6RlLaZEVXUyjUlFpUPusr4=
=fhyM
-----END PGP SIGNATURE-----