I cant seem to see why ... maybe i have been looking at the code too long, but the Welcome and selection part load only once first up, though when a selection is made, it displays it twice ...
Code:#include <stdlib.h> #include <stdio.h> void initialise(); void listDir(); void displayBitmap(); struct DirEntry { int UserCode; char FileName[9]; char FileExt[4]; char Extent; int BlockCount; int DiskBlock[16]; } DirSys[32]; char Bitmap[23]; char selct; int main() { do { printf(" ------------------\n"); printf(" Welcome to \n"); printf(" My CP/M Simulator \n"); printf(" ------------------\n"); printf(" Enter (i)nitialise, (l)ist directory, (d)isplay bitmap or (e)xit: "); scanf("%c", &selct); printf("\n"); switch (selct) { case 'i': initialise(); break; case 'l': listDir(); break; case 'd': displayBitmap(); break; case 'e': exit(0); break; } }while(1); ; } void initialise() { int i, j; /*Initialise bitmap */ Bitmap[0]=254; for (i=1; i <23; i++) Bitmap[i]=255; /*Initialise Directory */ for (j=0; j <32; j++) DirSys[j].UserCode = -1; } void listDir() { int j, count; printf(" ----------------------------------- \n"); printf(" File Name | File Type | Block Count \n"); printf(" ----------------------------------- \n"); for (j=0; j <32; j++) { if (DirSys[j].UserCode != -1) printf("%s %s %i \n",DirSys[j].FileName, DirSys[j].FileExt, DirSys[j].BlockCount); else (count++); } if (count == 32); printf(" ERROR: Empty Directory Structure \n"); } void displayBitmap() { int i,lb=0; unsigned char m; for(i=0;i<23;i++) { m=1; while(m) { if(Bitmap[i]&m) { printf(" "); putchar('1'); } else { printf(" "); putchar('0'); } m<<=1; lb++; if(lb%20==0) putchar('\n'); } } printf("\n\n"); }



LinkBack URL
About LinkBacks


