There are a few problems here. One of them is as you suspect, you cannot delete
something that was statically defined. That problem can be got past by having a static definition and an initialization function that performs the dynamic allocation and copies the static data in.
Another issue is that you're using call-by-value on the temp
variable. This might be less than obvious since, as you know, you're able to modify the data temp
points to -- the problem is that you also want to perform temp = tempStruct;
where, presumably, you want to affect the caller's view of the value passed in... if you want to affect what the caller sees, you need to call-by-reference.