view getline.c @ 17:b1a93dc1601d

Makefile rules for normalize and cross product
author Josef "Jeff" Sipek <jeffpc@optonline.net>
date Fri, 02 Dec 2005 23:49:15 -0500
parents 43c7ce2fc334
children cc1adef5674e
line wrap: on
line source

#include <unistd.h>
#include <fcntl.h>

int main(int argc, char** argv)
{
	char c;
	int fd;

	if (argc < 2)
		write(2, "error", 5);

	if ((fd = open(argv[1], O_RDONLY | O_NONBLOCK)) == -1)
		write(2, "error", 5);

	while((read(fd, &c, 1) == 1) && (c != '\n'))
		write(1, &c, 1);

	return 0;
}