replace cin with getchar()