Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
you cannot call
strlen()
on something likeThis is a char array, not a null-terminated string.
strlen()
works by iterating through the string until it finds a nul byte ('\0'
).vowels
does not contain one, so it will keep scanning the memory until a nul byte happens to be there by chance. this is undefined behavior and should be avoided at all costs. In the sample tests you are just being lucky.Also, performance note: you should almost never call
strlen()
in a loop on the same string: this makes your program slower for no reason; because unless the string's length is modified during the loop,strlen()
will keep doing the exact same operation again and again and return the same result every time