jweinst1
1/28/2018 - 9:22 PM

experiments with holding pointers in void

experiments with holding pointers in void

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

// simulates void casters
#define Val_NEW malloc(sizeof(Val))

typedef struct
{
	int i;
	char c;
	struct Val* next;
} Val;

typedef struct
{
	void* obj;
} Hold;


int main(int argc, char const *argv[])
{
	Hold test;
	Val* val = Val_NEW;
	val->i = 51;
	test.obj = val;
	Val* newval = test.obj;
	printf("The int is %d\n", newval->i);
	const char* foo = "Hello!";
	const char* doo = "Hello!!";
	printf("is good %d\n", strcmp(foo, doo));
	return 0;
}