9p / who / tweedy / 9C / 1


Exercise 1.6: Verify EOF

Code

#include <u.h>
#include <libc.h>
#include <bio.h>

#define STDIN   0

void
main()
{
    Biobuf *bstdin;
    bstdin = Bfdopen(STDIN, OREAD); 

    print("Enter a character:\n");
    print("`Bgetc(bstdin) != Beof` is %d\n", Bgetc(bstdin) != Beof);

exits(0);
}

Output

$ 9c verify.c; 9l verify.o -o verify
$ ./verify 
Enter a character:
f
`Bgetc(bstdin) != Beof` is 1
$ ./verify 
Enter a character:
`Bgetc(bstdin) != Beof` is 0



tweedy