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

How are Structure passing and returning implemented by the compiler?

1126


Differentiate between late binding and early binding. What are the advantages of early binding?

1027


What are pointers, when declared, intialized to a) NULL b) Newly allocated memory c) Nothing. Its random

1125


How would you differentiate between a pre and post increment operators while overloading?

1141


What is a null object in c++?

1223


What are c++ variables?

1060


What is the arrow operator in c++?

1013


What is helper in c++?

1085


What is type of 'this' pointer? Explain when it is get created?

1011


How does a copy constructor differs from an overloaded assignment operator?

1030


Difference between a copy constructor and an assignment operator.

996


Can you explicitly call a destructor on a local variable?

1028


Difference between overloaded functions and overridden functions

1051


What is data types c++?

1014


What is a constructor and how is it called?

1044