+ 1
.length in c++?
how to fix this? https://code.sololearn.com/cM7s7U5D9hz4/?ref=app I want to *Output* "aaa bbb ccc ddd eee fff" without using i<6, in java they use i<z.length https://code.sololearn.com/c1qDoEd8ds04/?ref=app
3 Respuestas
+ 4
i<(int)(sizeof(z)/sizeof(string))
because sizeof gives you the size of the array in bytes and you have to divide by the memory size of each element, that is sizeof(string)
But even easier is to use
i < (int) size(z)
+ 2
Do like this i < (int) (sizeof(z)/sizeof(z[0]))
sizeof (z) gives size in bytes.