Type command source code for displaying text file content

xiaoxiao2021-03-06  92

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 usage (char * msg) {PUTS (MSG); PUTS ("Usage: command filename1 [filename2] ..."); / * can display multiple file content * / exit (0) }

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;}

转载请注明原文地址:https://www.9cbs.com/read-107553.html

New Post(0)