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 constructor and destructor in c++?
What is a manipulative person?
What are the different types of comments allowed in c++?
What is data type in c++?
What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0
What is stack unwinding?
How do you initialize a string in c++?
How the virtual functions maintain the call up?
What is the maximum combined length of command line arguments including the space between adjacent arguments?
Why ctype h is used in c++?
Why #include is used?
Is it possible to write a c++ template to check for a function's existence?
State the difference between pre and post increment/decrement operations.
What is expression parser in c++
Of the numbers 12 23 9 28 which would be at the top of a properly implemented maxheap a) 28 b) 9 c) Any of them could be