You just created a new mystruct pointer. That means:
You get allocated a memory block, large enough to hold a address, and assign it to the pointer which is pointing to a pointer that points to a mystruct
member.
That doesn't mean, that there is a valid address hold in the pointer which you expect to be pointing to a mystruct
element. Even more currently there isn't even a valid address, where the pointer to the pointer is pointing on, as you just assigned a valid memory area to it, what doesn't mean there is a usefull address stored in.
So at all, what you want is:
You want a pointer which has a valid memory block to store a address in of another pointer, which is pointing to a valid memory area, where is a (probably valid) mystruct
stored in.
What you are doing is: you are requesting a memory area where you COULD (what you aren't even doing) store a poitner to another pointer... and so on.
so what you should do is:
mystruct **foo = new mystruct *;
*foo = new mystruct;