Simple shell----A little exercise in MOS

Source: Internet
Author: User
Tags strcmp


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.