0
For sure.. Condition
A valid username needs to be minimum 4, maximum 20 characters long. if(sizeof(name) >= 4 && sizeof(name) <= 20 ) Is true ?
2 odpowiedzi
+ 5
Sizeof returns the bytes in the string.
You have to use .length() method...
Like this
For sure.. Condition
if(name.length() >= 4 && name.length() <= 20 )
+ 1
No, the sizeof() operator will return the size in bytes of memory the variable is.
You could still use it to do some math and figure out how many chars name is though, but it's much easier to just get the length of the string.
https://www.w3schools.com/cpp/cpp_strings_length.asp