void show_sort(Node*head,int flag) { int cont=0; Node*p=head,*q;//->next,*q; if (head == NULL || head->next == NULL) return; for(p;p!=NULL;q=p,p=p->next,free(q)) { if((flag&A==0)&&(p->filename[0]=='.')) continue; if(flag%L==0) { display_l(p->fullname,flag); printf("\t%s\n",p->filename); } else { display(p->filename); cont++; if(cont%5==0) printf("\n"); } } printf("\n"); }
node* iith_end(node *head) { //Approach 1: count the nodes and apply for loop from behind with two pointers differencing in their position by 1 node *p,*q,*r,*temp; int pos,count=1; printf("\n Enter position from end : "); scanf(" %d",&pos); temp=(node *)malloc(sizeof(node)); printf("\n Enter rno: name: marks: "); scanf(" %d %s %d",&temp->rno,temp->name,&temp->marks); //firstly counting no of elements r=head; while(r->next!=NULL) { count++; r=r->next; } //now using formula count-pos-1 from starting p=head; q=p->next; for(c=0; c<(count-pos-1) ; c++) { p=p->next; q=q->next; } p->next=temp; temp->next=q; printf("\n Node inserted at the specified position \n"); display_l(head); return head; }
void show (DIR* dir_ptr,char *dirname,int flag) { int Flag,cout=0,l; struct dirent *direntp; struct stat buf; l=strlen(dirname); dirname[l]='/'; dirname[l+1]='\0'; while((direntp=readdir(dir_ptr))!=NULL) { char fullname[4096]; strcopy(fullname,dirname,direntp->d_name); if(((flag%A)!=0)&&(direntp->d_name[0]=='.')) continue; if(flag%U==0) Flag=true; if(flag%L==0) { display_l(fullname,Flag); printf("\t%s\n",direntp->d_name); } else { display(direntp->d_name); cout++; if(cout%5==0) printf("\n"); } } printf("\n"); }
Tr_level Tr_newLevel(Tr_level p, Temp_label n, U_boolList f) { Tr_level l = checked_malloc(sizeof(*l)); l->parent = p; l->name = n; l->frame = F_newFrame(n, U_BoolList(TRUE, f)); l->formals = makeFormalAccessList(l); #ifdef F_P display_l(l); #endif return l; }