What does this code do?? can anyone explain with comments??.. i make out some of it butttttttt we never really learned the struct part. And whats the size of a struct?? We also never learned the (->) is that another way of using a pointer?? Thanks
Code:#include "includes.h" /* struct foo2 { int val; struct foo2 *next; }; */ void function2 (int arg1) { int ii; struct foo2 *head = NULL; struct foo2 *item; for (ii = 0; ii < 16; ii++) { item = (struct foo2 *) malloc(sizeof(struct foo2)); if ( (arg1 >> ii) & 0x1) item->val = 1; else item->val = 0; if (head == NULL) { head = item; item->next = NULL; } else { item->next = head; head = item; } } printf("%d: ", arg1); item = head; while (item != NULL) { printf("%d", item->val); item = item->next; } printf("\n"); }



LinkBack URL
About LinkBacks


