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

Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;

1972


Mention the ways in which parameterized can be invoked.

899


What is a c++ object?

1107


What is recursion?

1959


How can you create a virtual copy constructor?

1042


Which software is used to run c++ program?

956


How can we read/write Structures from/to data files?

1073


What do you mean by inheritance in c++?

1037


Why do we need c++?

993


Can static member variables be private?

1125


Is main a class in c++?

966


Which operator cannot overload?

997


Is java easier than c++?

962


What is c++ good for?

1015


What is a buffer c++?

998