Why void data is useful :-)

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Wed Jul 11 02:47:58 AEST 1984


Void data is uniquely suited to putting in WOM (Write-Only Memory);
since sizeof(void) is 0, one can pack a lot of data into the WOM.

/* Example of void data -- inspired by UNIX code */

/*ARGSUSED*/
main( argc, argv )
	int	argc;
	char	*argv[];
	{
	char	c;			/* I/O character buffer */
	void	status;			/* system call return status */

	for ( ; ; )
		{
		status = (void)read( 0, &c, 1 );
		if ( (int)c == '\n' )
			break;
		status = (void)write( 1, &c, 1 );
		}
	exit( 0 );			/* nothing can possibly go wrong */
	}



More information about the Comp.lang.c mailing list