First, the purpose of the experiment
(1) Recognize DOS;
(2) Master the Principle of command interpretation procedure;
(3) Master the Simple Dos call method;
(4) Master C language programming preliminary.
Second, the contents and requirements of the experiment
Write a command-line interpreter similar to Dos,unix
(1) Self-defined system prompt
(2) Custom set of commands (8-10)
(3) User input Help to find commands
(4) List the function of the command, distinguish internal or external commands
(5) User input quit quit
(6) Internal commands are dir, CD, Md,rd, CLS, date, time, Ren, copy, etc.
According to the requirements, complete the design, coding, testing work.
Test methods, steps and Results
3. Main procedural paragraphs and their explanations:
#include <stdio.h>
#include <string.h>
Main ()
{
Char cmd[20][20]={"dir", "CD", "MD", "RD", "CLS", "Date", "Time", "Ren", "Copy", "Help", "quit"};
Char str[20];
while (1) {
printf ("Please enter the indicator:");
Gets (str);
if (strcmp (str,cmd[0]) ==0)
{
printf ("dir means no parameters: View files and folders in the current directory \ n");}
else if (strcmp (str,cmd[1]) ==0)
{
printf ("CD directory name: Enter a specific directory. \ n ");}
else if (strcmp (str,cmd[2]) ==0)
{
printf ("MD Directory name: Create a specific folder. Dos under the habit called Directory, win under the habit called folder \ n ");}
else if (strcmp (str,cmd[3]) ==0)
{
printf ("Rd Directory name: delete a specific folder.") \ n ");}
else if (strcmp (str,cmd[4]) ==0)
{
printf ("CLS Directory Name: Indicates clear screen function \ n");}
else if (strcmp (str,cmd[5]) ==0)
{
printf ("Data set date command, function is set date \ n");}
else if (strcmp (str,cmd[6]) ==0)
{
printf ("Time system clock Settings command, function: Set or display system period.") \ n "); }
else if (strcmp (str,cmd[7]) ==0)
{
printf ("Ren" means that the file is renamed, and the Ren command is in the format: the file name of the Ren source file name.) \ n ");}
else if (strcmp (str,cmd[8]) ==0)
{
printf ("Copy means copy command, copy information of his function \ n"); }
else if (strcmp (str,cmd[9]) ==0)
{
printf ("No Parameters: View files and folders in the current directory \ n");
printf ("CD directory name: Enter a specific directory. \ n ");
printf ("MD Directory name: Create a specific folder. Dos under the habit called Directory, win under the habit called folder) \ n ");
printf ("Rd Directory name: delete a specific folder.") \ n ");
printf ("CLS Directory Name: Indicates clear screen function \ n");
printf ("Data set date command, function is set date \ n");
printf ("Time system clock Settings command, function: Set or display system period.") \ n ");
printf ("Ren" means that the file is renamed, and the Ren command is in the format: the file name of the Ren source file name.) \ n ");
printf ("Copy means copy command, copy information of his function \ n");}
else if (strcmp (str,cmd[10]) ==0)
return 0;
Else
{
printf ("You enter the wrong information, please re-enter: \ n");
}
}
}
Iv. Summary of the experiment
This experiment is not too difficult, just a long time did not use C language to do the program, a little to find the beginning of the direction, and finally chose a relatively simple if-else statement to do this program. Although it is a bit simple to do, but in the process of doing it will encounter some small problems, such as missing symbols and so on.
10.10 DOS Test