Hii
I need to implement internal command :clear,dir <directory> ,environ and quit in C program using Unix..
i wrote program but i m not sure with output whether it is right or wrong
here is my code:
when i run my program i need to enterCode:#include <stdio.h> #include <unistd.h> #include <sys/types.h> int main(int argc, char *argv[]) { int i,n; char *s; //extern char **environ; extern char **environ; if(argc==2) { printf("Myshell??"); scanf("%s",s); if(strcmp(s,"clear")==0) { system("clear"); } else if(strcmp(s,"quit")==0) { exit(0); } else if(strcmp(s,"environ")==0) { while(*environ) printf("%s\n",*environ++); } } return 0; }
a.out r
Myshell??clear
and gives output to clear sceen
but how to implement quit command(exit)and dir <directory>command??
Help me..
Thanks
Rupal


Reply With Quote