TL;DR You cannot because the requirement is invalid from C point of view. Array sizes are fixed and cannot grow or shrink whatever be the usage requirement.

Quoting C11, chapter §6.7.6.2, Array declarators (emphasis mine)

In addition to optional type qualifiers and the keyword static, the [ and ] may delimit an expression or *. If they delimit an expression (which specifies the size of an array), the expression shall have an integer type. If the expression is a constant expression, it shall have a value greater than zero. [...]

Also, as per the Initialization syntax, C11, chapter §6.7.9, the brace closed initializer list should have at minimum one initializer element (object). An initializer in form of { }; is invalid C.


Note:

If you meant "How do I make the contents of an array empty in C?", well, in that case, assuming "empty" translates to a value of 0, we can use memset() or a loop-and-assignment to get that done. This, however, makes the array contents empty, not the size of the array.

Answer from Sourav Ghosh on Stack Overflow
Top answer
1 of 4
5

TL;DR You cannot because the requirement is invalid from C point of view. Array sizes are fixed and cannot grow or shrink whatever be the usage requirement.

Quoting C11, chapter §6.7.6.2, Array declarators (emphasis mine)

In addition to optional type qualifiers and the keyword static, the [ and ] may delimit an expression or *. If they delimit an expression (which specifies the size of an array), the expression shall have an integer type. If the expression is a constant expression, it shall have a value greater than zero. [...]

Also, as per the Initialization syntax, C11, chapter §6.7.9, the brace closed initializer list should have at minimum one initializer element (object). An initializer in form of { }; is invalid C.


Note:

If you meant "How do I make the contents of an array empty in C?", well, in that case, assuming "empty" translates to a value of 0, we can use memset() or a loop-and-assignment to get that done. This, however, makes the array contents empty, not the size of the array.

2 of 4
3

Try executing these two cases, so that you can understand what's actually going on with gcc.

CASE 1:

#include<stdio.h>
int main()
{
 int arr[]={};
 printf("size:%d\n",sizeof(arr));
}

CASE 2:

#include<stdio.h>
int main()
{
 int arr[]={};
 arr[0]=100;
 printf("size:%d\n%d\n",sizeof(arr),arr[0]);
}

This is because name of an array represents the address of base element. Also, if you declare an array with particular size, you cannot define the boundaries and you can access memory even out of boundaries till the segment in which the array is declared exhausts out of memory.

Coming to your code factors[] = {};, you cannot do this because this is not declaration of the array factors, though you are trying to assign no values using the {} construct. You can leave the [] empty only when you are initializing the array.

🌐
GeeksforGeeks
geeksforgeeks.org › c language › how-to-check-if-empty-array-in-c
How to Check if Empty Array in C? - GeeksforGeeks
July 23, 2025 - This means that the compiler doesn't know either the size of the array or its elements. So, it can't use any of them to make the array have a particular size. As a result, the array hasn't got any space to contain elements, which is why the ...
🌐
Quora
quora.com › How-do-you-create-an-empty-array-in-C
How to create an empty array in C - Quora
Answer (1 of 10): Empty Array in C : [code]#include #define size 100 void main() { char name[size] ; // Empty array declaration clrscr(); printf(“Enter your name : ”); gets(name); printf(“Welcome to the magical world of Programming %s”, name); getch(); } [/code]
🌐
GeeksforGeeks
geeksforgeeks.org › c language › how-to-empty-a-char-array-in-c
How to Empty a Char Array in C? - GeeksforGeeks
July 23, 2025 - We can empty a char array in C by setting all of the elements to ‘\0’. So, we can change every index element to '\0', as the first element is '\0' so the char array[] will be treated as empty.
🌐
Cprogramming
cboard.cprogramming.com › c-programming › 81033-empty-array.html
Empty Array
Thanks...i have no code for this yet cause i have no clue how to start an empty array thanks devilsknight ... You don't have to have it empty. Just fill it up and keep track of your last entry (assuming you aren't using the entire thing). There is no "empty" state in C.
🌐
DigitalOcean
digitalocean.com › community › tutorials › initialize-an-array-in-c
Initialize an Array in C | DigitalOcean
August 4, 2022 - We can also combine this with our old initializer list elements! For example, I am setting only array index arr[0], arr[8] as 0, while the others are designated initialized to 10!
Find elsewhere
🌐
Nim Forum
forum.nim-lang.org › t › 6706
Empty c-style array - Nim forum
I mean let's say a function takes an array parameter, with some (or no) values. I could obviously declare it as a seq, but then we would deal with memory allocation. I can also declare it as an openArray, and then I can pass both an array with values and an empty one, e.g. proc myFunc(a: openArray[int], b: openArray[int]) = ....
🌐
SEI CERT
wiki.sei.cmu.edu › confluence › display › c › MSC19-C.+For+functions+that+return+an+array,+prefer+returning+an+empty+array+over+a+null+value
MSC19-C. For functions that return an array, prefer returning an empty array over a null value - SEI CERT C Coding Standard - Confluence
Many functions have the option ... pointer cannot be produced. Some functions return arrays, which appear like a pointer to an object. However, if a function has the option of returning an array or indicating that a valid array is not possible, it should not return NULL. Instead, the function should return an empty ...
🌐
Jeremy Lindsay
jeremylindsayni.wordpress.com › 2017 › 10 › 07 › two-ways-to-initialize-an-array-in-c
Two ways to initialize an array in C | Jeremy Lindsay
October 7, 2017 - I don’t often post about C, but I’ve been programming a lot in the Arduino world recently, and thought I’d post a quick couple of tips on a small programming challenge I encountered. I needed to declare a character array (of length 64) – this is pretty simple.
🌐
Cplusplus
cplusplus.com › forum › beginner › 37180
arrays.... - C++ Forum
As exposed above, an array of ints can't have "empty" elements. However, you can always determine a convention if you want to. For instance, if you're only interested in positive integers, you could use -1 to signal an "empty" slot (maybe define a const int empty = -1).
🌐
Sololearn
sololearn.com › en › Discuss › 1857864 › how-to-check-for-an-empty-array
How to check for an empty array? | Sololearn: Learn to code for FREE!
✓to check whether an array is empty or not just iterate the elements of the array and compare them with null character '/0'. ✓you can also declare an empty array like this arr[]={}. Then use the sizeof function, if it returns 0 your array ...