home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource1
/
cenvid
/
tee.cmm
< prev
next >
Wrap
Text File
|
1993-03-26
|
863b
|
32 lines
// 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 <FileSpec>\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");
}