You should not need to cast malloc if you are using a modern C compiler. If you are compiling on a C++ setting, you would have to cast malloc, and would be posting on the C++ boards, and then probably using new/new[] anyways. All you would probably have to do with your IDE to compile it as a C program would be to change the extension from .cpp to .c