I have a struct defined as:
typedef struct ltsaNode {
int call;
int action;
ltsaNode *nextActions;
ltsaNode *sibling;
} ltsaNode;
And a struct pointer *wanted
and an int i
I want to check if any of the structs in wanted
has call
equal to i
.
My current solution:
BOOL a = FALSE;
for(;wanted!= NULL;wanted->sibling)
{
if(wanted->call == i)
{
a=TRUE;
break;
}
}
Is there a better or faster way to do this ?
This is what you are looking for I guess.
BOOL a = FALSE;
for(; wanted != NULL; wanted = wanted->sibling)
{
if(wanted->call == i)
{
a = TRUE;
break;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.