Using C language,I can use `feof` to test if the pointer at end of file.

```
while(!feof(fp))
{
    //to do
}

```

But in the mma,I usually use this method to simulate C.

```
file = OpenRead["http://home.ustc.edu.cn/~xiaozh/SE/stu.dat", BinaryFormat -> True];    
Reap[While[(tempRecord = BinaryRead[file, "Byte"]) =!= EndOfFile, 
     Sow@tempRecord]][[2, 1]]        
(*same as BinaryReadList[file,"Byte"]*)
Close[file];

```

> 
> {0, 0, 0, 0, 97, 0, 0, 0, 1, 0, 0, 0, 98, 0, 0, 0, 2, 0, 0, 0, 99, 0, 
>  0, 0, 3, 0, 0, 0, 100, 0, 0, 0, 4, 0, 0, 0, 101, 0, 0, 0, 5, 0, 0, 0, 
>  102, 0, 0, 0, 6, 0, 0, 0, 103, 0, 0, 0, 7, 0, 0, 0, 104, 0, 0, 0, 8, 
>  0, 0, 0, 105, 0, 0, 0, 9, 0, 0, 0, 106, 0, 0, 0, 10, 0, 0, 0, 107, 0, 
>  0, 0, 11, 0, 0, 0, 108, 0, 0, 0, 12, 0, 0, 0, 109, 0, 0, 0, 13, 0, 0, 
>  0, 110, 0, 0, 0, 14, 0, 0, 0, 111, 0, 0, 0, 15, 0, 0, 0, 112, 0, 0, 
>  0, 16, 0, 0, 0, 113, 0, 0, 0, 17, 0, 0, 0, 114, 0, 0, 0, 18, 0, 0, 0, 
>  115, 0, 0, 0, 19, 0, 0, 0, 116, 0, 0, 0, 20, 0, 0, 0, 117, 0, 0, 0, 
>  21, 0, 0, 0, 118, 0, 0, 0, 22, 0, 0, 0, 119, 0, 0, 0, 23, 0, 0, 0, 
>  120, 0, 0, 0, 24, 0, 0, 0, 121, 0, 0, 0, 25, 0, 0, 0, 122, 0, 0, 0}
> 
> 
> 

But this time I want to use mma to load the struct structure not bytes.

```
file = OpenRead["http://home.ustc.edu.cn/~xiaozh/SE/stu.dat", BinaryFormat -> True];
Reap[While[(tempRecord = BinaryRead[file, "Integer32"]) =!= EndOfFile,
     Sow@{tempRecord, BinaryRead[file, "Character8"]}; 
     Skip[file, "Byte", 3]]][[2, 1]]
Close[file];

```

> 
> {{0, "a"}, {1, "b"}, {2, "c"}, {3, "d"}, {4, "e"}, {5, "f"}, {6, 
>  "g"}, {7, "h"}, {8, "i"}, {9, "j"}, {10, "k"}, {11, "l"}, {12, 
>  "m"}, {13, "n"}, {14, "o"}, {15, "p"}, {16, "q"}, {17, "r"}, {18, 
>  "s"}, {19, "t"}, {20, "u"}, {21, "v"}, {22, "w"}, {23, "x"}, {24, 
>  "y"}, {25, "z"}}
> 
> 
> 

So I want to know if we can define a feof function to make the process more like C?

***PS***:The stu.dat was generated by C++.

And it define a struct structure.

**The first member is the index of the student,the second is its name.**

```
#include <iostream>
#include <stdio.h>
using namespace std;

typedef struct student
{
    int id;
    char name;
}stu;

int main()
{
const int num=26;
student stu[num];
memset(stu,0,sizeof(student)*num);

for(int i=0;i<num;i++)
{
    stu[i].id=i;
    stu[i].name=(char)(97+i);
}
for(int i=0;i<num;i++)
    cout<<stu[i].id<<" "<<stu[i].name<<endl;

FILE* fp = fopen("C:\\stu.dat","wb");
fwrite(stu,sizeof(student),num,fp);
fclose(fp);
return 0;
}

```