Firstly, your code is terribly formatted! There are literally hundreds of extra carriage returns and the indenting is very irregular, making the code pretty much unreadable. Please show some effort and format you code in a sensible manner, rather than expect the reader to put in the extra effort to understand it. You will be much more likely to get a response that way. Also, have you tried to compile this code? I would say not, since there are a number of errors. For instance, you have used int **m = malloc(r*sizeof(int *)); which will not compile since, malloc() returns void * . You need to explicitly cast the return-type to int ** , like int **m = (int **)malloc(r*sizeof(int *)); . Also, in your function matrix_mul() you try and check for an error and then on finding it, you have return 1; , but 1 is of integer type, not int ** , which is what you declare the return-type of the function to be. You should at leasttry and compile your code! Incidentally, the standard way to do this kind of error-checking is to use the return value as an indicator of errors and pass a pointer to the variable that you want to put the result in.
To answer your question: why don't you just keep using p , but with the elements multiplied by 50? If you need to use a different variable name, you can just do int **q = p; and then use q as you would have p . This doesn't copy the values or anything though, you'll be writing over the old ones. Is that what you want?