Se non dici che errori ti dà è difficile aiutarti...
Amaro C++, il gusto pieno dell'undefined behavior.
Regole del Forum