Does anyone know if their is a way to instantiate a structure in C at runtime? Thanks in advance.
Quote from: tpekar on January 22, 2014, 08:47:09 PM
Does anyone know if their is a way to instantiate a structure in C at runtime? Thanks in advance.
Sure, that's what malloc() is for.
struct data *my_data = (struct data *)malloc(sizeof(struct data));
Ralf
PS: You also might want to check the online help for the functions free(), calloc() and realloc() ;)
Thanks Ralf. I've done this before. I think I was just suffering from brain rot. Had to re-educate myself. :P
Quote from: tpekar on January 23, 2014, 08:34:12 PM
Thanks Ralf. I've done this before. I think I was just suffering from brain rot. Had to re-educate myself. :P
Been there, done that, didn't get the T-shirt (either).... ;D
Ralf ;)