I am using strcat to build a string. It works except for when I want to append characters that represent numbers from an array. The line that uses:
strcat(JsonDataStr, numsToSend[i]);
for example appends the character 'c' instead of '1'. If I manually put the character in using double quotes it works, but i want to have a one dimensional array with characters only.
char JsonDataStr[20];
void buildJsonString(){
int offset;
char strtStr[] = "[{\"" ;
char numStr[4];
char numsToSend[4] = {'1', '2','3','4'};
offset = sizeof(strtStr);
strcat(JsonDataStr, strtStr);
for(i = 0 ; i < 2 ; i++){
strcat(JsonDataStr, JsonDataName);
ByteToStr(i, numStr);
strcat(JsonDataStr, numsToSend[i]);
strcat(JsonDataStr, "\":\"");
}
strcat(JsonDataStr, "\"}]");
}
Any idea why this is happening.