Saturday, November 24, 2012

Very Simple My Own Shell in C

Do you want to publish source codes in your blog or web site as follows.
Visit Source Code Formatter
 #include<stdio.h>  
 #include<stdlib.h>  
 #include<string.h>  
 int main(){  
       char buf[256]={0};  
       printf("\n\n\n");  
       while(1){  
            printf("\nMOSH : ");  
            if (fgets(buf, sizeof(buf), stdin) == NULL){  
                fprintf(stderr, "Invalid input command!\n");  
                exit(-1);  
              }  
              buf[strlen(buf)-1]='\0';  
            system(buf);  
       }       
       return 0;  
 }  

0 comments:

Post a Comment