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

Mention the ways in which parameterized can be invoked. Give an example of each.

1002


What is the difference between #import and #include in c++?

1057


What is an iterator class in c++?

1088


What is the use of "new" operator?

1066


What is pointer in c++ with example?

1008


Why do we use structure in c++?

998


Comment on local and global scope of a variable.

1084


Define upcasting.

984


Would you rather wait for quicksort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) a) Quicksort b) Linear Search c) Bubble Sort

989


Differentiate between C and C++.

1172


Who discovered c++?

984


Write a recursive program to calculate factorial in c++.

1024


What is fflush c++?

952


Array base access faster or pointer base access is faster?

2238


What are the advantages of using const reference arguments in a function?

1021