You are looking for Enumerable.Empty<T>().

In other news the Java empty list sucks because the List interface exposes methods for adding elements to the list which throw exceptions.

Answer from Stilgar on Stack Overflow
Discussions

.net - How to empty a list in C#? - Stack Overflow
Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal. ... The 2026 Annual Developer Survey Results Site is liveโ€” view the results here! Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... I want to empty a list... More on stackoverflow.com
๐ŸŒ stackoverflow.com
stack - How to empty a list - Stack Overflow
Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Save this question. Show activity on this post. I was trying to figure out the way to empty a list (seen as a stack) in Common Lisp. More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to check if a linked list is empty in C - Stack Overflow
I have this code: I try to initialize a pointer and after i use it to check if my list is empty #include #include typedef long T; typedef struct SortedList { T More on stackoverflow.com
๐ŸŒ stackoverflow.com
Check if list is empty in C# - Stack Overflow
I have a generic list object. I need to check if the list is empty. How do I check if a List is empty in C#? More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Medium
medium.com โ€บ @e_moreira โ€บ stacks-in-c-a-comprehensive-guide-to-lifo-data-structures-f246312c938b
Stacks in C: A Comprehensive Guide to LIFO Data Structures | by Eric Moreira | Medium
March 7, 2026 - The isEmpty operation checks if the stack contains any elements. Empty Stack: Non-Empty Stack: โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ† TOP โ”‚ 5 โ”‚ โ† TOP โ””โ”€โ”€โ”€โ”€โ”€โ”˜ โ”œโ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ 3 โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”ค ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ implement-stack-in-c
Stack in C - GeeksforGeeks
September 2, 2026 - We know that when the stack is empty, the top is equal to -1. ... Else return false. The push function will add (or push) an element to the stack. The edge case here will be when we try to add a new element when the stack is already full. It is called stack overflow and we have to check for it before inserted new element.
๐ŸŒ
Medium
medium.com โ€บ @noransaber685 โ€บ understanding-the-stack-data-structure-in-c-introduction-implementation-and-examples-8d3fb03de809
Understanding the Stack Data Structure in C: Introduction, Implementation, and Examples | by Noran Saber Abdelfattah | Medium
June 17, 2023 - Itโ€™s usually done with an array or linked list. Elements are added or taken from one end of a stack, which is generally referred to as the โ€œtopโ€ of the stack. The maximum number of items that can be stored in static memory allocation in a stack is predetermined. Assume we have a stack with a capacity of 100 items. A stack overflow problem, often known as โ€œstack full,โ€ happens when the stack has reached its limit and no more components may be added.
Find elsewhere
๐ŸŒ
Programtopia
programtopia.net โ€บ home โ€บ c programming โ€บ stack data structure
Stack Data Structure - Programtopia
January 15, 2021 - If the stack is empty then the isEmpty function returns true value and no item can be removed from the stack. If the stack is not empty then the isEmpty function returns false value and we remove the top item from the stack by decrementing top ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ dsa โ€บ implement-stack-using-array
Stack using Array - GeeksforGeeks
Dynamic arrays automatically resize themselves as elements are added or removed, which makes the stack more flexible. In C++, we can use vector. In Java, we can use ArrayList. In Python, we can use list. In C#, we can use List. In JavaScript, we can use Array. ... #include <iostream> #include <vector> using namespace std; class myStack { vector<int> arr; public: // push operation void push(int x) { arr.push_back(x); } // pop operation int pop() { if (arr.empty()) { cout << "Stack Underflow" << endl; return -1; } int val = arr.back(); arr.pop_back(); return val; } // peek operation int peek() {
Published: December 15, 2025
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ stack-using-linked-list-in-c
Stack Using Linked List in C - GeeksforGeeks
December 12, 2025 - Here, the stack overflow will only occur if there is some error allocating the memory in the heap so the check will be done in the creation of the new node. The pop function will remove the topmost element from the stack. As we know that for stack, we need to first remove the most recently inserted element. In this implementation, the most recently inserted element will be present at the head of the linked list. ... Check if the stack is empty...
๐ŸŒ
Programming Line
learn.programmingline.com โ€บ home โ€บ c stacks
C Stacks Tutorial: LIFO, Arrays & Linked Lists
July 17, 2026 - Array-based stacks are fast but bounded in size; linked-list stacks grow dynamically but require careful memory management. Always guard against overflow (array-based) and underflow (both types) before performing an operation.
๐ŸŒ
Medium
medium.com โ€บ the-coding-handbook โ€บ c-programming-stack-419eaba2226e
C Programming โ€” Stack
September 8, 2026 - The reasons it occurs are usually (1) the static array size is set too small, or (2) the program falls into an infinite loop, constantly calling itself, leading to the exhaustion of internal Stack space.
๐ŸŒ
Uncodemy
uncodemy.com โ€บ blog โ€บ stack-implementation-in-c-push-pop-peek-with-code-examples
Stack Implementation in C | Push, Pop, Peek with Code Examples
Exit\n"); printf("Enter your choice: "); scanf("%d", &choice); switch (choice) { case 1: push(); break; case 2: pop(); break; case 3: peek(); break; case 4: display(); break; case 5: return 0; default: printf("Invalid choice\n"); } } return 0; } void push() { int val; if (top == SIZE - 1) printf("Stack Overflow\n"); else { printf("Enter value to push: "); scanf("%d", &val); stack[++top] = val; } } void pop() { if (top == -1) printf("Stack Underflow\n"); else printf("Popped element: %d\n", stack[top--]); } void peek() { if (top == -1) printf("Stack is empty\n"); else printf("Top element: %d\n", stack[top]); } void display() { if (top == -1) printf("Stack is empty\n"); else { printf("Stack elements: "); for (int i = 0; i <= top; i++) printf("%d ", stack[i]); printf("\n"); } }
๐ŸŒ
Cplusplus
cplusplus.com โ€บ reference โ€บ list โ€บ list โ€บ empty
std::list::empty
Returns whether the list container is empty (i.e. whether its size is 0). This function does not modify the container in any way.
๐ŸŒ
DataFlair
data-flair.training โ€บ blogs โ€บ stack-in-c-cpp
Stack in C/C++ - Master the LIFO Concepts in Less Than 4 Mins. - DataFlair
July 23, 2021 - In case we wish to display the data elements of the stack or perform the deletion operation, but no elements have been inserted into the stack yet, this condition is called STACK-EMPTY.
Top answer
1 of 2
1

First of all you don't need double pointer. Initialization with NULL is important here. (Denotes the empty list).

SortedList *list = NULL;

This has the benefit that now if you want to make changes to it pass it's address.

func(&list);

And checking the empty list would be

   void func(SortedList **list){
      if( *list == NULL )
        /* empty */
   }

This is usually the way lists are implemented.


In your case you simply allocated to a local variable and instead of returning the memory address you have overwritten the pointer's value with NULL - there is memory leak in the code.

With your code it will be something like. Yes all that the initialization does is assigning it to NULL. This is one easy way out towards checking the NULL. At the very beginning making it NULL basically denotes that list is empty.(which is the case generally).

2 of 2
0

list is a pointer to a pointer. The actual list is in the value it points to, so you need to dereference it.

An empty list is just a null pointer, so you don't need to allocate anything in init().

void init(SortedList** list)
{
    *list=NULL;
    printf("%p\n", *list);
}
void isEmpty(SortedList** list)
{
    printf("%p\n", *list);
    if(*list == NULL) printf("List is empty\n");]
}

And in the main function, you don't need a double pointer, you use the & (address-of) operator to get the address of a pointer variable.

int main()  
{
    SortedList *list;
    init(&list);
    printf("Initialization with succes\n");
    isEmpty(&list);

    return 0;
}

You only really need double pointers for functions that modify the list. So you could use an ordinary pointer for isEmpty:

void isEmpty(SortedList* list)
{
    printf("%p\n", list);
    if(list == NULL) printf("List is empty\n");]
}

and then call it as:

isEmpty(list);

But it's probably simplest to be consistent across all your functions.

๐ŸŒ
Codingzap
codingzap.com โ€บ home โ€บ blog โ€“ programming & coding articles โ€บ how to implement a stack using linked list in c?
How To Implement A Stack Using Linked List in C? - Codingzap
April 13, 2022 - When the stack is full, no more elements can be pushed into it, hence it results in Stack Overflow. isEmpty: The isEmpty operation in Stack checks if the stack is empty or not. When the stack is empty, no more elements can be popped from it, hence it results in Stack Underflow. Now, let us look into what is a linked list.
๐ŸŒ
VisiGrab
visigrab.com โ€บ topics โ€บ stack
Stack Data Structure: Push and Pop, Animated Step by Step
1 month ago - Only a bounded stack, such as one ... memory runs out. Stack underflow is a pop or peek on an empty stack: top = -1 in an array, top = null in a linked list....