Go Down

Topic: Code help (Read 3747 times) previous topic - next topic

AWOL

Quote
It is declared, but after the (incorrect) assignments to its elements.
Therefore, it is not declared!
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

tuxduino

No way this is going to compile:

Code: [Select]

two_character_string[0] = 0;
two_character_string[1] = 0;

char two_character_string[2] = {0, 0};


even if we move the two_character_string declaration _before_ the assignments.

The reason is you can't have an assignment operation outside a function, unless it's an initialization assignment.

So the 2-chars array _is_ declared and initialized. The problem is those two assigments and the fact that (in the original code) the initialization uses a not-yet-declared char variable.

But we're just splitting hairs I guess :)

PaulS

Move lines 16 and 17:
Code: [Select]
two_character_string[0] = c;
two_character_string[1] = 0;

into the function where you try to use the array, just before
Code: [Select]
       LCDString(two_character_string);

That should make all the error messages go away.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy