It depends on the type of file and how you're reading it.
Assuming you're reading a text file:
int main()
{
    char buf[1024];
    FILE *fptr;

    fptr = fopen( "file.txt", "rt" );
    if( fptr == NULL )
    {
        // file didnt open, so exit
        printf( "Unable to open file.\n" );
        exit(1);
    }

    buf = fgets( buf, 1024, fptr );
    while( buf != NULL )
    {
        // do something with that 1024 byte block, eg print it
        printf( "%s", buf );
        buf = fgets( buf, 1024, fptr );
    }
    return 0;
}

That should do quite nicely, providing i havent made any mistakes :)

----- Original Message -----
From: "Christopher Long" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 07, 2002 11:52 AM
Subject: Re: [hlcoders] file reading from...


when using c++ file streams to detect end of file you can do something like

ifstream if;
if.open("filename", flags);
while(!in.eof() )
{
read lots of stuff in
}
in.close();

i am not fluent with c's file openings and such but i have managed to open
files read from it etc but what i now require is how to check using c style
syntax whether its at end of file or not?

So basically what is the c style end of file check i can use in my while and
if loops??? botman anyman :) ???

thanks peoples.



_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to