Computer Science Canada dos utility |
Author: | alpesh [ Sat Oct 02, 2004 10:22 am ] |
Post subject: | dos utility |
![]() ![]() ![]() turbo c++ ----------------- #include<stdio.h> #include<stdlib.h> #include<conio.h> void main() { char *command[]={ "DIR", "CHKDSK", "TIME", "DATE", "LABEL" }; char ch; for( ; ; ) { do { int i; clrscr(); printf("Prg. To Run DOS Commands\n"); printf("1.DIR\n"); printf("2.CHKDSK\n"); printf("3.TIME\n"); printf("4.DATE\n"); printf("5.LABEL\n"); printf("6.EXIT\n"); printf("\nchoice : "); ch=getche(); printf("\n"); } while((ch<'1') || (ch>'6')); if(ch=='6') break; system(command[ch - '1']); } } |
Author: | Dan [ Sat Oct 02, 2004 11:15 am ] |
Post subject: | |
Wow that is some unportable code....thats only going to work on windows and even then on compliers that only let you do void main. Ushely it is a good idea to use int main so you can return an error code to the OS (witch in this case whould prity much have to be windows...). Edit: Also the way you are using that for loop is not realy that good progaming, i whould use a while or do loop in it's place. |
Author: | JHanson90 [ Sat Oct 02, 2004 5:58 pm ] |
Post subject: | |
alpesh, you might consider enclosing your source in [code] tags to make it appear correctly on the page, so it's more readable. |
Author: | wtd [ Sat Oct 02, 2004 6:03 pm ] |
Post subject: | |
As I noted in your other threa, but will note here again for emphasis, that is not C++ code, but rather C code. The two are quite different languages. |
Author: | wtd [ Sat Oct 02, 2004 6:35 pm ] | ||
Post subject: | |||
And, for educational porpoises, the whole thing cleaned up.
|