Well. Say the user inputs "Hey" in the "input". So now string input = "Hey".
input.lenght = 3 bytes. Because there are 3 characters.
If string input = "Yellow" it would be equal to 6 bytes.
So the
1 2 3 4
|
f(input.length()==3)
{newcard='X';
newsuite=input[2];
}
|
Does this. If input.lenght == 3 (in this case it is, because the user entered "hey")
Then what it does is that, it assigns char newcard the character X. So now if you print out newcard you will get "x".
Then it assigns newsuite the third letter of string input, which is in this case the "y".
this -
1 2 3 4 5
|
else
{newcard=input[0];
newsuite=input[1];
}
|
this is triggered if input is more or less than 3 bytes.
So, if what the user inputs (say the example from before, the user inputs "Yellow")
Then it will assign newcard the first letter of that word. so newcard will be = 'Y'.
newsuite will be assigned the second letter of that word. so newsuit will be = 'o'.
Hope it helped.