Mail Archives: djgpp/2000/05/21/20:53:41
thank you all for the response. the reason I to know the the allocated
memory size:
i am trying to read a text file with comma seperated values into
an array. The only way i figuered i could do that is by allocating
memory and adding new elements to the array. The length of this
array would be needed if i try to sort it or search the
contents...
I think keeping track is the only way to know the amount of memory.
thank you all again
chaitanya b
Chris Mears wrote:
>
> On Sat, 20 May 2000 05:47:31 +0600 (LKT), that hoopy frood Kalum
> Somaratna aka Grendel wrote:
>
> >On Fri, 19 May 2000, Hans-Bernhard Broeker wrote:
> >
> >> In article <39249FAE DOT F0428E1F AT fujixerox DOT co DOT jp> you wrote:
> >> > I am sorry if my question are too silly. I am absolute novice at
> >> > programming in C and that is the reason for the question.
> >>
> >> > Problem:
> >> > Is there any way I can find out the number of bytes of memory that has
> >> > been allocated to a pointer.
> >>
> >> None that would be reliable. If you think you need that information,
> >> you'll have to keep track of it yourself.
> >
> >Actually Why would you need to know how much of bytes has been allocated
> >to a pointer...
>
> Perhaps so that you don't overrun an array's bounds. For example:
>
> void fill(int *array, size_t elem)
> {
> size_t i;
>
> for (i = 0 ; i < elem ; i++) {
> array[i] = i;
> }
> }
>
> In this case you need to know the amount of storage that the array has
> been allocated.
>
> --
> Chris Mears
> ICQ: 36697123
--
**************************************************************
B. Chaitanya
Senior Systems Engineer
Wipro Technologies
Survey No. 64, Serilingampalli Mandal,
Madhapur, Hyderabad - 500033
Tel: 81-090-7005-4697
Fax:
E-mail: Chaitanya DOT Burgupalli AT wipro DOT com (Wipro Technologies)
Chaitanya DOT Burgupalli AT fujixerox DOT co DOT jp (Fuji-Xerox)
www.wipro.com
The World's First SEI CMM Level 5 Software Services Company
**************************************************************
- Raw text -