SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By AbolfazlNejatian
#195451
hey, everyone, I'm going to use an alphabetic keypad for my project bu I couldn't understand this line of
Code: Select all
buildStr[buildCount++] = (isalpha(key)) ? virtKey : key;
i approciate anyone could help me;

many thanks
Abolfazl
By Valen
#195452
Code: Select all
buildStr[buildCount++] =
Here it assigns an element in the array (string?) buildStr at index buildCount to what is evaluated after the equal symbol. After the value is assigned buildCount is also incremented (postfix execution). The content of the array element is determined by the following.
Code: Select all
(isalpha(key)) ? virtKey : key;
This evaluation is a kind of if-statement. If the result of the function isalpha(key) is true, then the result is virtKey, otherwise key.

Since I have no idea what buildCount, the function isalpha, key or virtKey means I can't tell why this is meant to be so. The rest of your program would provide context to this. Based on common naming convetions buildStr is likely a string.
By AbolfazlNejatian
#195456
thank you, dear, @Valen
this line enough for me!

"This evaluation is a kind of if-statement. If the result of the function isalpha(key) is true, then the result is virtKey, otherwise key."