replaced printf with cout, need to fix read access violation