Az array length az a tömb mérete, vagy a tömb elemeinek a száma, ha nincs a tömb teljesen feltöltve?
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz1.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz1.png)
C#-ban a tömb összes elemének a száma:
"Gets the total number of elements in all the dimensions of the Array."
Javaban is:
"Returns the length of the specified array object, as an int."
Javascriptben is:
"The length property of an object which is an instance of type Array sets or returns the number of elements in that array."
Pythonban is:
" len(s)
Return the length (the number of items) of an object. The argument may be a sequence (such as a string, bytes, tuple, list, or range) or a collection (such as a dictionary, set, or frozen set)."
Pascalban is:
"For dynamic or static arrays, the function returns the number of elements in the array. "
C/C++-ban a sizeof operátor a bájtban meghatározott méretét adja vissza a tömbnek:
"1) Returns the size, in bytes, of the object representation of type
2) Returns the size, in bytes, of the object representation of the type of expression. No implicit conversions are applied to expression.
...
If the type of expression is a variable-length array type, expression is evaluated and the size of the array it evaluates to is calculated at run time.
(since C99)
Number of elements in any array a including VLA (since C99) may be determined with the expression sizeof a / sizeof a[0]. Note that if a has pointer type (such as after array-to-pointer conversion of function parameter type adjustment), this expression would simply divide the number of bytes in a pointer type by the number of bytes in the pointed type."
Viszont az std::array::size már a tömb elemeinek a számát:
"Returns the number of elements in the array container."
int szamok[10] = {1, 2, 3, 4, 5};
5 vagy 10 a length?
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz2.png)
![*](http://static.gyakorikerdesek.hu/p/vsz1.png)
Kapcsolódó kérdések:
Minden jog fenntartva © 2025, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!