Demo entry 3822492



Submitted by anonymous on Mar 01, 2016 at 04:27
Language: C++. Code size: 633 Bytes.

#include <unistd.h>
#include <sys/uio.h>
#include <stdio.h>
#include <fcntl.h>

int main(int argc, char *argv[])
	ssize_t iSize;
	char acBuf1[9];
	char acBuf2[9];
	struct iovec iov[2];

	int iFd1 = open(argv[1], O_RDONLY);
	int iFd2 = open(argv[2], O_RDONLY);
	int iFd3 = open(argv[3], O_WRONLY);

	iSize = read(iFd1, acBuf1, sizeof(acBuf1));
	iSize = read(iFd2, acBuf2, sizeof(acBuf2));

	iov[0].iov_base = acBuf1;
	iov[0].iov_len = sizeof(acBuf1);
	iov[1].iov_base = acBuf2;
	iov[1].iov_len = sizeof(acBuf2);

	iSize = writev(iFd3, iov, 2);

	return 0;

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).