Line | |
---|
1 | /*
|
---|
2 | * getw - read a word from a stream
|
---|
3 | */
|
---|
4 | /* $Header: /cvsup/minix/src/lib/other/getw.c,v 1.1.1.1 2005/04/21 14:56:27 beng Exp $ */
|
---|
5 |
|
---|
6 | #include <stdio.h>
|
---|
7 |
|
---|
8 | _PROTOTYPE(int getw, (FILE *stream ));
|
---|
9 |
|
---|
10 | int getw(stream)
|
---|
11 | register FILE *stream;
|
---|
12 | {
|
---|
13 | register int cnt = sizeof(int);
|
---|
14 | int w;
|
---|
15 | register char *p = (char *) &w;
|
---|
16 |
|
---|
17 | while (cnt--) {
|
---|
18 | *p++ = getc(stream);
|
---|
19 | }
|
---|
20 | if (feof(stream) || ferror(stream)) return EOF;
|
---|
21 | return w;
|
---|
22 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.