文件在此
也有源码:
#include <time.h>
#include<stdio.h>
#include<graphics.h>
#include "dir.h"
#include "string.h"
#include "conio.h"
#include "errno.h"
#include "dos.h"
#include "io.h"
#include "process.h"
#include <stdlib.h>
#define PAGEDOWN 20736
#define ESC 283
#define FALSE 0
#define TRUE 1
char *command_help[]=
{
"'change 'used to change the file's propty",
"'edit ' used to edit a text",
"'cd ' used to show the directary path",
"'type' used to list a file",
"'copy' used to copy a alredy exist file to another place",
"'delete ' used to delete files you want ",
"'mkdir' used to creat a content",
"'rmdir' used to delete a centent which has already existed",
"'chdir' change the path of files",
"'deldir' used to delete a content ",
"'move; used to move files",
"'format' used to format the disk",
"'fdisk',used to deal with partition",
"'quit',used to exit the OS"};
char *command[]={
"change",
"edit",
"cd",
"type",
"copy",
"delete",
"mkdir",
"rmdir",
"chdir",
"deldir",
"move",
"format",
"fdisk",
"quit"};
char str1[20];
void help();
void change();
void cd();
void type();
void copy();
void delete();
void makedir();
void remarkdir();
void changedir();
void deldir();
void move();
void format();
void memery();
void display_time(int color,int back_color,int x,int y)
{
time_t seconds;
time(&seconds); /*/ Get current time */
seconds += (time_t) 60 * 60 * 24;
printf("%s",ctime(&seconds));
getch();
}
void help()
{
}
void new_init()
{ cleardevice();
init();
}
init()
{ int t_color=1,background=2,x=0,y=0,gety;
int flag;
char s[10];
int score=100;
setbkcolor(1);
settextstyle(0,0,1);
settextstyle(0,0,2);
setcolor(2);
outtextxy(200,0,"CPU");
setcolor(3);
settextstyle(0,0,1);
sprintf(s,"process",score);
outtextxy(250,0,s);
rectangle(535,279,635,479);
rectangle(0,240,50,340);
/*setfillstyle(SOLID_FILL,1);*/
/* floodfill(10,10,4);*/
display_time(t_color,background,x,y);
setcolor(2);
outtextxy(0,20,"Ready queues:");
outtextxy(200,20,"Waiting queues:");
printf("\nCommand>");
scanf("%s",str1);
while(strcmp(str1,"quit")!=0)
{
if(strcmp(str1,"?")==0||strcmp(str1,"help")==0)help();
else if(strcmp(str1,command[0])==0)flag=1;
else if (strcmp(str1,command[1])==0)flag=2;
else if(strcmp(str1,command[2])==0)flag=3;
else if(strcmp(str1,command[3])==0)flag=4;
else if (strcmp(str1,command[4])==0)flag=5;
else if(strcmp(str1,command[5])==0)flag=6;
else if(strcmp(str1,command[6])==0)flag=7;
else if(strcmp(str1,command[7])==0)flag=8;
else if(strcmp(str1,command[8])==0)flag=9;
else if(strcmp(str1,command[9])==0)flag=10;
else printf("'%s' is not an effect command in this system!\n",str1);break;
/*lswitch(flag){
case 1:com(0);break;
case 2:com(1);break;
case 3:com(2);break;
case 4:com(3);break;
case 5:type();break;
case 6:com(5);break;
case 7:copy();break;
case 9:makedir();break;
case 10:com(9);break;
} */
flag=0;printf("Command>");
}
}
main()
{ int t_color=1,background=2,x=0,y=0,driver,mode,a;
int exit=FALSE;
char c;
driver=DETECT;
mode=VGA;
registerbgidriver(EGAVGA_driver);
initgraph(&driver,&mode,"");
init();
while(!exit)
{
if(kbhit())
{a=bioskey(0);
switch(a)
{
case PAGEDOWN:new_init();break;
case ESC:exit=TRUE;break;
}
}
}
getch();
}
是老师要求的模拟操作系统的作业,用TC 写,我写的是界面,有人告诉我为什么运行程序后要按其他按键Command才显示出来呢?有什么 解决方法?先谢谢各位了
----------------解决方案--------------------------------------------------------