jim lee
Well-known member
Ran into an issue in my code where I (assume) I have a c string allocated on my stack but the instant I write to it everything crashes.
Simple sketch to show this..
I swear this used to work. This code where the problem cropped up has been in there forever.. Well, I think its been in there forever. Anyway, has something changed? Or am I just going crazy and this has never been legal to do?
I put the blinking light in to show if the program survived or not.
Thanks!
-jim lee
Simple sketch to show this..
Code:
int led = 13;
void setup() {
Serial.begin(9600);
while(!Serial);
Serial.println("I'm here");
Serial.flush();
pinMode(led, OUTPUT);
trash("123456");
Serial.print("Still alive?!");Serial.flush();
}
void trash(char* inStr) {
Serial.println("in trash");Serial.flush();
inStr[0] = 'x';
Serial.println(inStr);Serial.flush();
}
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
I swear this used to work. This code where the problem cropped up has been in there forever.. Well, I think its been in there forever. Anyway, has something changed? Or am I just going crazy and this has never been legal to do?
I put the blinking light in to show if the program survived or not.
Thanks!
-jim lee