This is certainly wrong:
Code:
strcat ("0x", str);
The first argument to strcat must be a pointer to a character in an array of char that can be modified. Modifying a string literal results in undefined behaviour.
Rather:
Code:
strcpy(str, "0x");
strcat(str, &testData1[y]);
strcat(str, &testData1[s]);
Note that you will be overwriting str on each iteration of the for loop.
Furthermore, I suspect that you don't want to use strcat in this way, since you print testData1[y] and testData1[s] as chars, and y and s are consecutive. If so, you probaby want to write:
Code:
strcpy(str, "0x");
strncat(str, testData + i, 2);
str[4] = '\0';
Thus you do away with y and s.
Next, what are you trying to do in these two lines?
Code:
*(hex + t) = "0x" + *str;
int t = t+1;