Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is constructor and destructor in c++?

1163


What is a manipulative person?

1074


What are the different types of comments allowed in c++?

1026


What is data type in c++?

1054


What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0

995


What is stack unwinding?

1203


How do you initialize a string in c++?

1046


How the virtual functions maintain the call up?

1282


What is the maximum combined length of command line arguments including the space between adjacent arguments?

1033


Why ctype h is used in c++?

990


Why #include is used?

1114


Is it possible to write a c++ template to check for a function's existence?

1073


State the difference between pre and post increment/decrement operations.

1141


What is expression parser in c++

2555


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

1468