Re: [algogeeks] size of array

2013-02-03 Thread Prem Krishna Chettri
No We cannot use that information.. Reason 1 That is implantation of the compiler dependent and moreover is NOT expose. 2 When we use malloc to allocate memory in heap. its the base address of the value we get.. and incase of array there is no way you are restricted to put your values beyond your

Re: [algogeeks] size of array

2013-01-31 Thread Piyush
it will always work if array is statically allocated Not if dynamically allocated, say using malloc etc. On 30-Jan-13 1:55 PM, Prem Krishna Chettri wrote: @Piyush .. Never works.. @All there is no way to do the given requirement in pure C. On Wed, Jan 30, 2013 at 1:45 PM, Piyush

Re: [algogeeks] size of array

2013-01-31 Thread Abhirup Ghosh
When malloc allocates memory it assigns a size field in the header to indicate the size of the memory it allocates at a stretch. Can we not use this information effectively? On Jan 31, 2013 11:44 PM, Piyush piyush.to...@gmail.com wrote: it will always work if array is statically allocated Not

Re: [algogeeks] size of array

2013-01-30 Thread Piyush
sizeof(array)/sizeof(array[0]) On 28-Jan-13 3:44 PM, Anil Sharma wrote: How to calculate the size/lenght of an int array which is passed as an ONLY argument to a function??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] size of array

2013-01-30 Thread Prem Krishna Chettri
@Piyush .. Never works.. @All there is no way to do the given requirement in pure C. On Wed, Jan 30, 2013 at 1:45 PM, Piyush piyush.to...@gmail.com wrote: sizeof(array)/sizeof(array[0]) On 28-Jan-13 3:44 PM, Anil Sharma wrote: How to calculate the size/lenght of an int array which is

Re: [algogeeks] size of array

2013-01-30 Thread Nishant Pandey
i already said this is not possible , in my intial draft , as we dont have any information of memory owner in called function , just have base address which is address of single element of the array . On Wed, Jan 30, 2013 at 1:55 PM, Prem Krishna Chettri hprem...@gmail.comwrote: @Piyush ..

[algogeeks] size of array

2013-01-29 Thread Anil Sharma
How to calculate the size/lenght of an int array which is passed as an ONLY argument to a function??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [algogeeks] size of array

2013-01-29 Thread Nishant Pandey
i think this is not possible as you are passing only base address of the int array to it , there is not information about the owner . On Mon, Jan 28, 2013 at 3:44 PM, Anil Sharma anilsharmau...@gmail.comwrote: How to calculate the size/lenght of an int array which is passed as an ONLY argument

Re: [algogeeks] size of array

2013-01-29 Thread naveen bansal
If the array was declared as int array[100]; then sizeof operator will give you the size of that array. then length can found as length = sizeof(array)/sizeof(int); if the array was declared dynamic then you can not find the length of that array. Naveen On Mon, Jan 28, 2013 at 3:44 PM, Anil