23 lines
422 B
C
23 lines
422 B
C
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<fcntl.h>
|
|
#define BUFSIZE 256
|
|
|
|
int main(int argc, char * argv[]){
|
|
int f,n;
|
|
char buf[BUFSIZE];
|
|
if(argc<2){
|
|
fprintf(stdin,"Usage: %s <file-to-read>\n",argv[0]);
|
|
exit(1);
|
|
}
|
|
f=open(argv[1],O_RDONLY);
|
|
if(f==-1){
|
|
perror("Opening file failed !");
|
|
exit(2);
|
|
}
|
|
while((n=read(f,buf,BUFSIZE))!=0){// pas oublier les parentheses
|
|
write(1,buf,n);
|
|
close(f);
|
|
exit(0);
|
|
}
|
|
} |