1. your BYTE arraysmay not have been initialized to '\0' as string,
and 0 for nums. Use

memset(&array,'\0',sizeof(array) ) -
this initializes any integer variable to 0 and sets strings to zero-length.

2. your pointers are aimed to outerspace. Use assert.

3. You're taking chars --> DWORD as I recall,, so after playing around the buffers will have wierd stuff in them. Re-initalize if necessary.

Plus, you're completely sure that your BYTE arrays have valid data in them, right? See #4

4. if you mess with strings, string operations leave crud in memory after the trailing '\0' character, especially after several strcpy operations on the same piece of memory. File i/o's (like fgets) can leave \n at the tail of the string, too.

And it's not a weird problem at all, especially in C.