#include #include #include #include main() { struct nodetype { int temper,ups,count; struct nodetype * next; }; typedef struct nodetype * nodeptr; nodeptr p,q,top; FILE * fp; char *word; int temp,h,c,prev,prenum,i=0; if (!(fp=fopen("syslog","r"))) {printf("Syslog not found");exit(1);}; top = (nodeptr) malloc(sizeof(struct nodetype)); p=top; p->next=NULL; while (!(feof(fp))) { fscanf(fp,"%s",word); if (strcmp(word,"UPS")==0) { fscanf(fp,"%d",&temp); p->ups=temp; p->count=i; i++; } else if (strcmp(word,"is")==0) { fscanf(fp,"%d",&temp); if (!feof(fp)) { p->temper=temp; q=p; p = (nodeptr) malloc(sizeof(struct nodetype)); q->next=p; } p->next=NULL; } } q->next=NULL; p=top; printf("FINISHED READING\n"); prev=0;c=0; printf("UPS 0\n"); for(h=40;h!=25;h--) { printf("%d",h); while(p) { if ((h==p->temper)&&p->ups==0) { c=0; while ((p->count-prev-c)>0) {printf(" ");c++;} printf("*"); prev=(p->count+1); p=p->next; } else p=p->next; } printf("\n"); prev=0; p=top; } printf("Press ENTER...");getchar();printf("UPS 1\n"); for(h=40;h!=25;h--) { printf("%d",h); while(p) { if ((h==p->temper)&&p->ups==1) { c=0; while ((p->count-prev-c)>0) {printf(" ");c++;} printf("*"); prev=(p->count+1); p=p->next; } else p=p->next; } printf("\n"); prev=0; p=top; } }