Добавил:
Fragga
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:лабораторки по ОС препод Челноков / prog / copy_8
.c#include <fcntl.h>
#include <sys/types.h>
#include <signal.h>
#define bufsize 256
static int print_result(int);
int main(int argc, char *argv[])
{
static int counter=0;
int number=0;
if(argc<4){
printf("[file1] [file2] [file3]");
exit(0);
}
char buf1[bufsize+1], buf2[bufsize+1];
int fd1 = open(argv[1],O_RDWR | O_CREAT);
int nread = read(fd1, buf1, bufsize);
if (nread <0)
{
perror("read");exit(3);
}
printf("[2]:file1 read ok\n");
buf1[nread]='\0';
int fd2 = open(argv[2],O_RDWR | O_CREAT);
int nread = read(fd2, buf2, bufsize);
if (nread <0)
{
perror("read");exit(3);
}
printf("[2]:file2 read ok\n");
buf2[nread]='\0';
int fd3 = open(argv[3],O_RDWR, | O_CREAT;)
char byte[256];
int i=0;
while(i!=256)
{
byte[i]=buf[i];
i=i+1;
int nread_out = write(fd_out,byte ,sizeof(byte) );
}
Соседние файлы в папке prog