+ 2
[SOLVED] New driver's license challenge
https://code.sololearn.com/c9nXkx0O2fz6/?ref=app it doesn't seem to run properly if the input is not single characters, does anyone know how to fix this?
5 Answers
+ 1
if(t[i]!=name1){
////////////////////
d++;
Here you store single character in t[] array but later you comparing with entire string so never comes true for multi character string..
try this :
if(t[i][0]!=name1[0]){
Hope it helps..
+ 2
i thought t[i] was a single character tho no wonder it dont work!
+ 1
Jayakrishna This make me wonder why do t[i][0]!=name[0] work out when t[i]!=name[0] dont
+ 1
t[i] is a string where name[0] is just a single character.. So you need casting for compatible types....
Or t[I][0] will give you a first character.
Vicent Roxan You're welcome..
0
Ohhhh that explain why