Pages: 1 2 [3]   Go Down
Author Topic: Code help  (Read 3139 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25847
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It is declared, but after the (incorrect) assignments to its elements.
Therefore, it is not declared!
Logged

"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.

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No way this is going to compile:

Code:
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 smiley
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Move lines 16 and 17:
Code:
two_character_string[0] = c;
two_character_string[1] = 0;
into the function where you try to use the array, just before
Code:
       LCDString(two_character_string);

That should make all the error messages go away.
Logged

Pages: 1 2 [3]   Go Up
Jump to: