Добавил:
Fragga
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:лабораторки по ОС препод Челноков / 2семестр / wi2 / AKAM / 4a
.c#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define SEGSIZE 80
#define CHAN "tstchnl"
#define str "test string"
main()
{
int fd;
int n;
char buff[SEGSIZE];
fd = open(CHAN, O_RDWR);
printf("Writing...\n");
while ((n = read(fd,buff,SEGSIZE)) > 0)
write(fd,str,n);
printf("Reading...\n");
read(fd,buff,SEGSIZE);
write(1,buff,strlen(buff));
close(fd);
exit(0);
}