The compiling of the command interpreter program, and the compiling of the command interpreter program
# Include <stdio. h>
# Include <string. h>
Main (){
Char order [15] [10] = {"dir", "cd", "md", "rd", "cls", "date", "time ", "ren", "copy", "help "};
Char string [10], a [10], B [5] [5] = {"YES "};
Int I, j, t = 0;
Printf ("Enter the command :");
Printf ("\ nDo you need help? YES or NO :");
Gets ();
For (I = 0; I <5; I ++ ){
If (strcmp (a, B [I]) = 0)
{
For (I = 0; I <10; I ++)
{
For (j = 0; j <10; j ++)
Printf ("% c", order [I] [j]);
}
Printf ("\ n enter the command :");
T = 1;
}
}
If (t = 0)
Printf ("\ n enter the command :");
For (I = 0; I <100; I ++ ){
Gets (string );
If (strcmp (string, order [0]) = 0)
Printf ("dir indicates no parameter: view the files and folders in the current directory. \ T this is an internal command \ n ");
Else if (strcmp (string, order [1]) = 0)
Printf ("cd directory name: enter a specific directory. \ T this is an internal command \ n ");
Else if (strcmp (string, order [2]) = 0)
Printf ("md directory name: create a specific folder. \ T this is an internal command \ n ");
Else if (strcmp (string, order [3]) = 0)
Printf ("rd directory name: delete a specific folder. \ T this is an internal command \ n ");
Else if (strcmp (string, order [4]) = 0)
Printf ("cls clear screen. \ T this is an internal command \ n ");
Else if (strcmp (string, order [5]) = 0)
Printf ("data set date command, function is set date \ t this is internal command \ n ");
Else if (strcmp (string, order [6]) = 0)
Printf ("time system clock setting command, function: set or display the system period. \ T this is an internal command \ n ");
Else if (strcmp (string, order [7]) = 0)
Printf ("Old ren file name New File Name: Change the file name. \ T this is an internal command \ n ");
Else if (strcmp (string, order [8]) = 0)
Printf ("copy path \ file name: copy one file to another. \ T this is an internal command \ n ");
Else if (strcmp (string, order [9]) = 0)
Printf ("help" indicates no parameter: view the files and folders in the current directory. \ T this is an external command \ n ");
Printf ("\ n enter the command :");
}
}
Summary: The programming process is still relatively smooth, because it is a familiar C language programming, so there is no major problem. The goal has been achieved, but I don't know if the program has a small error or is not well-considered. Feeling good!