Go Down

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


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.


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 :)


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]

That should make all the error messages go away.
The art of getting good answers lies in asking good questions.

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!

via Egeo 16
Torino, 10131