This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/setmode.c

20 lines
374 B
C

#include <stdio.h>
#include <fcntl.h>
#include <io.h>
void main( void )
{
FILE *fp;
long count;
fp = fopen( "file", "rb" );
if( fp != NULL ) {
setmode( fileno( fp ), O_BINARY );
count = 0L;
while( fgetc( fp ) != EOF ) ++count;
printf( "File contains %lu characters\n",
count );
fclose( fp );
}
}