The following...
Code:
#include <stdio.h>
#include <stdlib.h>
#include <utmp.h>
int main(void) {
FILE *f;
int n;
char buffer[1024];
f=fopen(_PATH_UTMP,"rb");
if (f==NULL) exit(0);
while (1) { /* trademark bartc loop */
n=fread(buffer,1,1024,f);
printf("N = %d EOF = %d\n",n,feof(f));
if (n<1024) {
printf("no more\n");
break;
}
}
fclose(f);
}
produces..
[cd@localhost oakland]$ gcc -g bart.c -o bart
[cd@localhost oakland]$ ./bart
N = 1024 EOF = 0
N = 1024 EOF = 0
N = 1024 EOF = 0
N = 1024 EOF = 0
N = 1024 EOF = 0
N = 1024 EOF = 0
N = 1024 EOF = 0
N = 512 EOF = 1
no more
[cd@localhost oakland]$
The question is, what is while being compared against to make this loop terminate. I mean,
Is just
So what is getting compared against not zero in this case?