How can you quickly find the number of elements stored in a
a) static array b) dynamic array ?
Answer Posted / jaroosh
a) sizeof(array)/sizeof(element)
b) you cant (well, you can, eg. by using realloc, counting
from 0 up, and checking the result etc. but this is absurd),
its best to keep track somehow how many elements are there
in the array, but the BEST solution is...do NOT use dynamic
arrays at all, use std containers instead like vector.
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is #include sstream?
What is the difference between a definition and a declaration?
What are containers in c++?
List the advantages of inheritance.
Do you know the use of vtable?
What does obj stand for?
What jobs can you get with a c++ certification?
Is it possible to have a recursive inline function in c++?
What do you mean by global variables?
What are vectors used for in c++?
What is the best c++ book for beginners?
How do I write a c++ program?
Explain what are single and multiple inheritances in c++?
If a function doesn’t return a value, how do you declare the function?
What is null c++?