With this code the output is the way that I wanted:
-23
But if I change the size of array2 from 6 to something such as 23 so the array become this: array2[23];
I get this:
└☼q-23
I don't know why when I change the size of array2 into 23 I get some junk before the actual content of the array. Am I missing something here? And am I using the strcat() function correctly?
array1 and array2 both contain junk so using strcat on them isn't useful. You need use null-terminated character arrays in order for strcat to work correctly.
The final array needs to be large enough to hold the result. There is no runtime check to do this for you, so you have to take care of this yourself. It's called a buffer overrun. http://en.wikipedia.org/wiki/Buffer_overrun