minimal.ino (3.55 KB)
minimal.ino (3.55 KB)
You have global variables and local variables with the same name. You are putting error text in the local version then displaying the global one which is never changed.
Incidentally, there is no need to use goto in your program. The worst example is goto Loop; in the aptly named loop() function.
Two absolute no goes in the code
First of all the goto's. Goto's make thing complecated and very unclear. It's considered bad practice and you can do easily without.
Second, less critical but still unnecessary. Stop using the String class. It's slow, buggy and not needed. Just create normal C strings. So
char errorString1 = "Asking failed ";
I tried to set the chars, but I get the following error:
expected unqualified-id before ‘[’ token
Some code I’m not going to show you generates an error that includes this snippet, among other useful stuff. What did I do wrong?
Did I summarize your post correctly?
char errorString1 = "asking failed";
Got the brackets in the wrong place.
Ah, yes, sorry! Had my thinking hat on backward or something :confused:
Had my thinking hat on backward or something
Looks like you had your C# hat on, not your C++ hat.
char ErrorstringA = "Asking failed "; // ... ... Setze String
Since you have the "char" in front, you are creating a new variable called ErrorstringA thta just happens to have the same name as the other one and only exists inside that while loop. It is destroyed when the while loop exits.
But, you defined ErrorstringA like this:
char ErrorstringA = "test";
Since you don't include a number in the brackets, the compiler looks at the length of your string and puts a 5 in there for you. So this char array is only 5 elements long, 4 letters and a null terminator. It could never hold all the letters you're trying to cram in it later. That would end up writing over other memory that doesn't belong to that array and causing all sorts of havoc with your program.
You need to define the ErrorstringA array to be big enough to fit the largest string you ever plan to put in there. Then to put a different string in there you would use the strcpy command.