Hiya BGI 5X,
From your description, I'm not entirely sure what the serial algo is but I can explain why your code isn't working.
First your while statement...
If you're dealing with a condition where the serial length really must be "less than" 10, using the "not equals" operator is ambiguous and fails to correctly describe the situation. Whether the length is 1 or 100 it still remains != 10.
while(length1 != 10)
should be
while(length1 < 10)
Next, look at heh[length1] += 0x39;
length1++;
This explains your problem of 1 '9' at the end of the string and shit in the rest of it.
Length1, being the length of the string, will start to index the heh array at the last element of the string (which explains the '9'at the end of the string). Then, presumably because the array size of heh is longer than the actual string length, length1++ proceeds to index past the last element in the string into the remainder of the array. If you did not initialize the contents of the array when you delcared it, you will now be adding 0x39 to whatever crap is already in those memory locations beyond your string resulting in the shit of which you speak. I should also mention that if your serial length were to be greater than 10, the length1 variable would never == 10 and terminate the while loop... Infinite Loop == crash
From your description, I'm not entirely sure of the serial algo. Are you adding the ascii value for 9 (0x39) to the existing ascii values of each element in the string or are you simply adding 9 (0x09)to the existing ascii values for the string elements. For the sake of example I'm going to assume you're adding 0x39. Also for this situation I would suggest a 'for' loop rather than a 'while' loop.
Example: If the serial length is less than 10 add 0x39 to each element in the string starting with the first element.
length1=strlen(heh);
if(length1 < 10)
{
for(int i=0; i<length1; i++)
heh[I]+=0x39;
}
Anyway, I hope this clears up a few of the bugs

If you post more details of the algorithm you're trying to code, I'm sure either myself or someone else around here can help you with your C.
Regards,
Clandestiny