while (variavel != (struct lista*)0) {
...
}
How to interpret (struct lista*)0)
? What does that mean?
while (variavel != (struct lista*)0) {
...
}
How to interpret (struct lista*)0)
? What does that mean?
(struct lista*)
is a cast , so the code tells the compiler to interpret the following value as being of this specified type, that is, a pointer to a structure named lista
previously declared . In this case it's just a way to make it clear that you know you're doing it and that's what you want, that is, the variable variavel
must be exactly of type struct lista *
, since 0
is originally a type int
, with cast is guaranteed to be compatible from the point of view of type. But of course, nothing guarantees that the data is what is expected there. The 0
in this case is a null pointer indicative, so the loop will stop when the value of variavel
is null.