String input changed from using scanf to malloc and getchar