home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Guide
/
c-cplusplus-interactive-guide.iso
/
c_ref
/
csource3
/
107_01
/
fio.2
< prev
next >
Wrap
Text File
|
1984-06-05
|
2KB
|
66 lines
/*********************************************
* This source code was contributed by: *
* *
* Eric Martz *
* Department of Microbiology *
* University of Massachusetts *
* Amherst, MA 01003 *
* *
* Phones: *
* *
* Day: 413-545-2325 *
* Evenings: 413-256-0751 *
* *
*********************************************/
/* For an example of the use of "fio.2" and an introduction, see "fio.1". */
/* "fio.2" SHOULD BE INCLUDED AS THE FIRST EXECUTABLE CODE IN MAIN;
IT ZEROS ALL bufuse ELEMENTS, INDICATING THAT NO BUFFERS ARE ASSIGNED
TO FILES INITIALLY. */
for(bufuse[0]=1;bufuse[0]<=NIOBUFS;bufuse[bufuse[0]++]=0);
/* THE NEXT STATEMENT LEAVES bufuse[0] SET AT NIOBUFS FOR
USE BY FOPEN, FCLOSE */
bufuse[0] -= 1;
/* End of fio.2 *
n a "word count" program:
---------------------------------------------------------
#include "bdscio.h"
#define NIOBUFS 1
#include "fio.1"
main(argc,argv)
int argc;
char **argv;
{
#include "fio.2"
if (argc == 1) {
printf("Use: wc filename\n");
exit(0);
}
allcnt(argv[1]);
}
allcnt(name)
char *name;
{
unsigned linecnt, charcn/*********************************************
* This source code was contributed by: *
* *
* Eric Martz *
* Department of Microbiology *
* University of Massachusetts *
* Amherst, MA 01003 *
* *
* Phones: *
* *
* Day: 413-545-2325 *
* Evenings: 413-256-0751 *
* *
****************