read write 3d array
solution with pointer array
bug fixed