Your code is correct, there is nothing wrong with it, but you are used to testing the return value of the malloc () function, if it is NULL, this will create a problem in your program, in our case, malloc () memory allocation does not work
source
share