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
How a new operator differs from the operator new?
What is math h in c++?
What are guid? Why does com need guids?
What is the fastest c++ compiler?
Which compiler does turbo c++ use?
How did c++ get its name?
What is the error in the code below and how should it be corrected?
Why c++ is not a pure oop language?
Describe Trees using C++ with an example.
What are the storage qualifiers?
Is it possible for the objects to read and write themselves?
What is #include cstdlib in c++?
Explain about Virtual Function in C++?
How we can differentiate between a pre and post increment operators during overloading?
Can create new c++ operators?