View Single Post
Join Date: May 2005
Posts: 4
Reputation: swets_here is an unknown quantity at this point 
Solved Threads: 0
swets_here swets_here is offline Offline
Newbie Poster

Re: get length of a dynamic array

 
0
  #4
May 31st, 2005
I guess this would be helpful,
/******for a static array********/
char inp[4];
for (n=0;inp[n];n++)
; //do nothing inside the loop
cout<<n; //n will display the number of elements in the array inp[]

/******for dynamic array********/
char *arr = new char [sizeof(char)];
for (n=0;arr[n];n++)
; //do nothing inside the loop
cout<<n; //n will display the number of elements in the array arr[]
Reply With Quote