Go Down

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

tuxduino

Tom, I think the OP wants to store the value of the char variable c into the first element of two_character_string, not the letter 'c'.

Code: [Select]

// otherwise, just print all normal characters
two_character_string[0] = c;
two_character_string[1] = 0;    // this can be put in setup()
LCDString(two_character_string);

Tom Carpenter


Tom, I think the OP wants to store the value of the char variable c into the first element of two_character_string, not the letter 'c'.

Code: [Select]

// otherwise, just print all normal characters
two_character_string[0] = c;
two_character_string[1] = 0;    // this can be put in setup()
LCDString(two_character_string);


Ahh right, in which case you just need to remove the ' '
Code: [Select]
char two_character_string[2] = {c,0};
~Tom~

PaulS

Quote
It should be this:

Most definitely not. The [2] index is all wrong for an array that has two elements.

Tom Carpenter

I'm sorry, in what way is the [2] wrong? It is a declaration of an array with two elements, which is initialised with two characters, 'c' and 0 (or in my last post is initialised with the value stored in the variable c and a 0).
~Tom~

PaulS

I read your previous post too quickly. It was correct. I was wrong. My apologies.

Go Up