Why can't we declare a variable length array in struct in C? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why can't we declare a variable length array in struct in C?

It's usual to get the length of an array and then declaring it. Then why can't we do the same in a struct? it's like... int arr[n]; is acceptable but struct number{ int arr[n]; } is not acceptable. In both n is taken from the user using scanf before declaring the array. So why does the compiler not accept the second form?

5th May 2018, 7:41 AM
srihitha reddy
srihitha reddy - avatar
0 Answers