Think of their own many pictures and code in the last time the hard drive was lost, Heart is the pain ...
This simple shell code was placed in a temporary PDF document that was preserved ... Amen... Today want to write a simple database, feel is not to do an interactive page, do not let users write programs, imitate the simple command of MySQL, the user fool is good ...
The way you interact can be the shell. In fact, the Chinese Academy of Sciences Monensin Teacher one of the first few lessons of OO class is to write a shell himself. Not hard. Rtfsc
So ... the demo is as follows:
/**********************************************file:shell_jason.ccode Writer:eofcode date:2014.05.13e-mail:[ email protected]**********************************************/#include <stdio.h> #include < Stdlib.h>char command[1024] = {0,};int main () {printf ("\t\t---------shell just for fun-------\t\n\n");p rintf ("\t\ TIf you don ' t know-just input help ^_^ \ n ");p rintf (":) #--> "); scanf ("%s ", command); while (strcmp (comma nd, "exit") {if (!strcmp (Command, "CD")) {System ("CD");} else if (!strcmp (command, "vim")) {System ("Vim");} else if (!strcmp (command, "ls")) {System ("LS");} else if (!strcmp (command, "date")) {System ("date");} else if (!strcmp (command, "Help")) {printf ("\n\tyou could input command like:cd,vim,ls and date.") "This shell is writed just for fun." "It would let's know what's the shell is." "Just enjoy it.\n" "Thank you!\n\t" "Jason leaster\n\n");} else{printf ("Sorry, I just a naive penguin\n");} printf ("\ n:)-"); scanf ("%s", command);} return 0;}
A little romance at sunset-taken in the summer of September 21 7 o'clock in the evening
Simple shell----A little exercise in MOS