+ 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?

21st Mar 2022, 10:29 AM
Vicent Roxan
Vicent Roxan - avatar
5 Respostas
+ 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..
21st Mar 2022, 11:08 AM
Jayakrishna 🇮🇳
+ 2
i thought t[i] was a single character tho no wonder it dont work!
21st Mar 2022, 1:58 PM
Vicent Roxan
Vicent Roxan - avatar
+ 1
Jayakrishna This make me wonder why do t[i][0]!=name[0] work out when t[i]!=name[0] dont
21st Mar 2022, 1:14 PM
Vicent Roxan
Vicent Roxan - avatar
+ 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..
21st Mar 2022, 1:27 PM
Jayakrishna 🇮🇳
0
Ohhhh that explain why
21st Mar 2022, 1:54 PM
Vicent Roxan
Vicent Roxan - avatar