|
下面的程序我不是原创。
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
int main( void )
{
int fd;
int size_read;
char buffer[80];
/* Open a file for input */
fd = open( "myfile.dat", O_RDONLY );
/* Read the text */
size_read = read( fd, buffer,
sizeof( buffer ) );
/* Test for error */
if( size_read == -1 ) {
perror( "Error reading myfile.dat" );
return EXIT_FAILURE;
}
/* Close the file */
close( fd );
return EXIT_SUCCESS;
}
sizeof()是什么意思?
请问这里的 O_RDONLY是什么意思?
请问这里的 EXIT_SUCCESS是术语吗?还是可以自己定义的? |
|