www.pudn.com > CENVID.rar > TEE.CMM
// Tee.cmm Send lines to screen and to output file
main(argc,argv)
{
if ( 2 != argc )
Instructions();
else {
// open ouput file
if ( NULL == (fp=fopen(argv[1],"w")) )
printf("Could not open file \"%s\" for writing.\a\n",argv[1])
else {
// read in each line, and send to file and screen
while ( NULL != (line=gets()) ) {
printf("%s\n",line)
fprintf(fp,"%s\n",line)
}
fclose(fp)
}
}
}
Instructions()
{
printf("Tee.cmm - Pipe output to screen AND to a file\n");
printf("USAGE: Tee.cmm \n");
printf(" Where: FileSpec = Name of file to create and write text to\n");
printf("Example: To see output of a dir listing, but also save it in a file:\n");
printf(" dir | cenvi tee.cmm dir.txt\n");
}