Hey there, i'm trying to copy char values into a char matrix, but i don't know why i'm having a strange result.
The reason of this, it's because i need a matrix to have all the values associated to a trayectory mission.
Here's the code:
char matrixMision[20][7][8];
int auxMision;
boolean listo = false;
void setup() {
Serial.begin(9600);
}
void newMision(int auxMision, float latitud, float longitud){
char numObjetivo[3];
String str = String(auxMision);
str.toCharArray(numObjetivo, 3);
strcpy(matrixMision[auxMision - 1][0], numObjetivo);
char estado[2];
estado[0] = 'P'; //default
estado[1] = '\0';
strcpy(matrixMision[auxMision - 1][1], estado);
char latitudObjetivo[9];
str = String(latitud ,4); //4 digits of precision
str.toCharArray(latitudObjetivo, 9);
strcpy(matrixMision[auxMision - 1][2], latitudObjetivo);
char longitudObjetivo[9];
str = String(longitud, 4); //4 digits of precision
str.toCharArray(longitudObjetivo, 9);
strcpy(matrixMision[auxMision - 1][3], longitudObjetivo);
listo = true;
}
void printMatriz(int auxiliar){
for(int i = 0 ; i < auxiliar ; i++){
for(int j = 0 ; j < 7 ; j++){
Serial.print(matrixMision[i][j]);Serial.print(",");
}
Serial.println();
}
}
void loop() {
auxMision = 1;
float latitud = -29.9670; //4 digits of precision
float longitud = -71.3564; //4 digits of precision
if(!listo){
newMision(auxMision, latitud, longitud);
}else{
Serial.println("Listo");
}
printMatriz(auxMision);
}
The output fot this it's quite rare:
OUTPUT:
Listo
1,P,-29.9670-71.3564,-71.3564,,,,
The problems it's in cursive letters. I don't really know why i'm getting in matrixMision[0][2] that union of values.