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 atoi in c++?
What do you mean by funtion prototype?
What are function prototypes?
What are the operators in c++?
How does c++ structure differ from c++ class?
What is setw manipulator in c++?
Can I learn c++ without knowing c?
what are the iterator and generic algorithms.
What do you mean by vtable and vptr in c++?
Why do you use the namespace feature?
What are separators in c++?
Define friend function.
How we can differentiate between a pre and post increment operators during overloading?
How is data hiding achieved in c++?
What is a class template in c++?