[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: IO



On Thu, 2006-02-09 at 17:56 -0500, Robbie wrote:

> I'm not sure why but I created a char *, write the char to it and it
> works that way instead of including the hex in the write function;
> something like write(fd, mychar, 1) instead of write(fd, "0x16",1).
> difference?

The second write writes the byte '0' (the first char of the string)
instead of the byte 0x16.  If you could take the address of a constant
in-place, you might have success with "write(fd, &0x16, 1)", but that's
not C.

I would suggest the following code:

	char c = 0x16;
	write(fd, &c, 1);

timo




Reply to: