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 #include sstream?

1108


What is the difference between a definition and a declaration?

1113


What are containers in c++?

1031


List the advantages of inheritance.

1180


Do you know the use of vtable?

1186


What does obj stand for?

1253


What jobs can you get with a c++ certification?

1105


Is it possible to have a recursive inline function in c++?

1073


What do you mean by global variables?

1123


What are vectors used for in c++?

1142


What is the best c++ book for beginners?

1205


How do I write a c++ program?

1168


Explain what are single and multiple inheritances in c++?

1069


If a function doesn’t return a value, how do you declare the function?

1108


What is null c++?

1179