jweinst1
10/24/2017 - 4:46 PM

allows a byte array to be accessed from any type via void pointers in C

allows a byte array to be accessed from any type via void pointers in C

#include <stdio.h>
#include <stdlib.h>

//implements a bytestream in c

int main(int argc, char const *argv[])
{
	unsigned char bytes[50]; 
	void* template = bytes; // allows bytes array to be used by any type of pointer
	int* intlist = template;

	*intlist = 666;
	printf("first 4 bytes are: %d %d %d %d\n", bytes[0], bytes[1], bytes[2], bytes[3]);
	return 0;
}