0

How to find array length in C Programming Language?

I was able to get length of array in C. But it is only giving me initial length of array not updated i.e., after adding new value in array. Here is mine program:: https://code.sololearn.com/cb1dF7V2ZVx9/?ref=app PLEASE HELP!

26th Oct 2020, 2:53 AM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
7 Antworten
+ 4
Yes, arrays are of fixed length. You might need to use dynimic arrays or another dynamic length data structure. a [3] = 55 is not adding a new element to the array. In order to understand it you should learn more about pointers and memory. Arrays are a continuous block of memory. https://www.sololearn.com/learn/C/2933/ Keep in mind that a[k] is the same as *(a + k).
26th Oct 2020, 3:23 AM
Kevin ★
+ 4
Yes it's possible and you did it well. What you need to understand is that you can't change the length of the array. It will remain the same. a [ 3 ] = 55 won't change the array. See my previous answer.
26th Oct 2020, 3:36 AM
Kevin ★
+ 2
Array is fixed length. Though C let you do so, but such thing could lead problems in the computer.
26th Oct 2020, 3:04 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
Ok Thanks!
26th Oct 2020, 11:39 AM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
0
Kevin ★ CarrieForle So, this is not possible to get array lenght
26th Oct 2020, 3:25 AM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar
0
Ok
26th Oct 2020, 3:37 AM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar