this is my code. It should be pretty simple, but I don't know what's going wrong. I have two arrays, and fill them with a character 'n'. That's it. It literally just fills the two char arrays with 'n' for every element. For some reason, my output is giving this: screenshot of serial output with wonky shtuffs What am I doing wrong here? Why is it filling with weird stuff, and why is the character array longer then I specified? When I switched the conditions to i < size for the two loops, I got even worse output.image with what I thought was better and origionally did but SHRUG Why is id array 3 instead of just size 1? Same for data array? Do i manually have to enter \0? I didn't think so?
const int idSize = 1;
const int dataSize = 7-idSize-2; //the two is \0 and :, id size is //1, 7 is starting bytes
//[id] [:] [1][2][3] [\0]
// 1 2 3 4 5 6, idk what the 7th byte is, but that is how // many I'm recieving when I print out howMany from wire recieve. //That code isn't included as it isn't important to the issue.
char idMessage[idSize];//1 character
char dataMessage[dataSize];//actual size would be howmany - idsize - 1, the -1 is - ':'. -1 isn't nessisary bc howmany-idsize returns the number, not 0123 but 1234
int id;
double data;
void setup(){
Wire.begin(9);
Serial.begin(115200);
}
void loop(){
for(int i = 0; i <= idSize; i++){//<= idsize means +1 in size, because starts at 0
idMessage[i] = 'n';//TODO fill back to front with the message to make sure that there are no extra zeros to wack stuff
// I tried the condition at i<dataSize and i < idSize, but those also didn't work :(
}
for(int i = 0; i <= dataSize; i++){
dataMessage[i] = 'n';///TODO fill back to front with the message to make sure that there are no extra zeros to wack stuff
}
Serial.print("idMessage ");
Serial.println(idMessage);
Serial.print("dataMessage ");
Serial.println(dataMessage);
}