Developpement/23SCR/SCR011/store_numb.c

30 lines
491 B
C

#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<stdlib.h>
#define szbuf 256
int main(int argc, char const *argv[])
{
char buf[szbuf];
int f1,f2,n,m;
if(argc<2)
{
fprintf(stderr, "Usage : %s <file_name>",argv[0]);
exit(1);
}
fd = open(argv[1],O_WRONLY|O_TRUNC|O_CREAT,0600);
if(fd == -1)
{
perror("Opening source file fails");
exit(2);
}
write (1, "Numb---> ", 9);
while(n = read (0, buf, szbuf)){
m = write (fd, buf, n);
if
}
close(fd);
exit(0);
}