deleted the typecasting in using malloc, typecasting is needed in C++ rather than C