ack/lang/cem/libcc.ansi/core/stdio/getw.c

22 lines
290 B
C
Raw Normal View History

1989-12-18 14:40:54 +00:00
/*
* getw - read a word from a stream
*/
1994-06-24 14:02:31 +00:00
/* $Id$ */
1989-12-18 14:40:54 +00:00
2018-06-21 20:33:47 +00:00
#include <stdio.h>
1989-12-18 14:40:54 +00:00
2018-06-21 20:33:47 +00:00
int getw(register FILE* stream)
1989-12-18 14:40:54 +00:00
{
register int cnt = sizeof(int);
int w;
2018-06-21 20:33:47 +00:00
register char* p = (char*)&w;
1989-12-18 14:40:54 +00:00
2018-06-21 20:33:47 +00:00
while (cnt--)
{
1989-12-18 14:40:54 +00:00
*p++ = getc(stream);
}
2018-06-21 20:33:47 +00:00
if (feof(stream) || ferror(stream))
return EOF;
1989-12-18 14:40:54 +00:00
return w;
}