First of all, you should not SHOUT.
Then, you should explain what is your problem.
Anyway, the following line is probably wrong:
if(*(p+i)==*(p+j))
You are comparing item from first array with item from the same array.
Also, it seems that when this line is executed,
tem
is not yet initialized to the desired value (but still 0):
for(k=0;k<tem;k++)>
Given that, that loop is never executed. Same problem a few lines below. You are probably using the wrong variables at some places in those loops.
Without looking further and without even trying your program, it is clear that it will not work as intended.
Then, your program is far from optimal. You allocated
r
at 2 places. The one in
main
is useless.
Also, if you sort both array, you don't have to compare each item in each array but you can add the minimum item form the current location in each array and you won,t need to sort the result once more at the end.
Alternatively, it you know that original arrays don't have duplicated or you want to removed duplicate, you might make a big array and sort it once then remove duplicates either in place or into a new array.