jeudi 24 décembre 2015

How is a true or false result determined if a struct or a pointer is used as the parameter to an if statement in C?

I've been reading other people's code, but the parameters people use to if statements are really confusing to me. I've seen people place pointers and structs as parameters, but I don't understand how it's decided whether the result of the logical statement will be true or false. For example:

 struct Foo foo;

if(foo)
doSomething();

char *ch = malloc(sizeof(char));

if(num)
doSomethingElse();

If someone were to write and compile this, how would a true of false result be determined from the logical statements in the if statements?

Aucun commentaire:

Enregistrer un commentaire