I am having a problem with passing a char*
to an array of char**
on my Teensy.
Below is the problematic part:
for (j = 0; j < rulesamountsingle; j++) {
emptybuffer(buff);
char temp[10];
while(!Serial.available());
len = Serial.available();
for (i = 0; i < len; i++) {
temp[i] = Serial.read();
}
temp[len-1] = 0;
fuzzyRulesSingle[j] = temp;
Serial.print(fuzzyRulesSingle[j]);
Serial.print('\n');
}
As you can see, fuzzyRulesSingle[j]
(where fuzzyRulesSingle
is a char**
) will be filled by the variable temp
(a char*
). As I increment j
, the next address in fuzzyRulesSingle
will be filled by a new temp
.
However, when I print my fuzzyRulesSingle
OUTSIDE the code above, all fuzzyRulesSingle
will be filled with the last value of temp.
Where have I gone wrong?