These two lines:
itoa(randominteger,testarray,10); // Generate ascii for number and place in testarray[]
strcpy(testarray,tmp); // Overwrite testarray with tmp
Your code trashes testarray[] with the second line above.
These two lines:
itoa(randominteger,testarray,10); // Generate ascii for number and place in testarray[]
strcpy(testarray,tmp); // Overwrite testarray with tmp
Your code trashes testarray[] with the second line above.