My guess is it's purely coincidental that your code worked on DOS.
Mustn't be much of a coincidence. Once I wrote a struct for a matrix of doubles that was initialized on input from a file and it used dynamic memory allocation.
I went on to make a heavy-duty Gauss-Jordan solver out of it and tested it with the given equations (it was an assignment in college). The program ran perfectly except for a memory access violation at the very end of execution after all the results had been obtained.
Turned out that I forgot to allocate memory for _any_goddamed_thing_! (That was supposed to be just one malloc()).
The compiler? TurboC++. (Don't ask me what _I_ was doing with TC++ :D)