Type command source code for displaying text file content
Today, learn documents, practicing ... LOOK / * NAME: X_TYPE.C Author: x-bit at 167168.kmip.net (Pure Technology Forum) Description: Type command source code DEV-CPP5 Win2k Debug is reproduced, please keep the integrity of the above information Date: 08-11-2004 Copyright: x-bit allrights reserved. * /
#include
Void errmsg (char * msg) {PUTS (MSG); exit (0);} void type (int Argc, char * argv []) {INT i; file * fp; for (i = 2; i <= argc; i ) / * loop display multiple files * / {if (fp = fopen (argv [i-1], "r")) / * Normal Open file display its content * / {PUTCHAR ('/ n'); PUTS (Argv [I-1]); While (! Feof (fp)) PUTCHAR (FGETC (FP));} else / * error message * / {PUTCHAR ('/ n'); PUTS (Argv [i-1] ); Errmsg ("can't Find the file.");} Fclose (fp);}}
INT Main (int Argc, char * argv []) {if (argc == 1) errmsg ("parameter error."); Else Type (argc, argv); return 0;}