You are returning a pointer to a stack memory location. That memory region is no longer valid once the function returns.

Also, instead of actually returning a pointer to the array, you are returning the first element in the array. The following code will return 1, not a pointer the array.

Use with AIint array[] {1, 2, 3, 4};
return *array

You probably only need to make minimal changes your code to get it to work.

Use with AIvoid** array = (void **) malloc(sizeof(void *) * array_size); 
...
return array;

Just make sure that you release the memory that memory used for array when you are finished with it.

Use with AIvoid **array = list_to_array(list);
// Use array
...
// Finished with array
free(array);
Answer from torak on Stack Overflow
🌐
w3resource
w3resource.com › c-programming-exercises › linked_list › c-linked_list-exercise-32.php
C Exercises: Convert a Singly Linked list into a array
October 16, 2025 - Linked List: Convert a Singly Linked list into an array: ------------------------------------------------------------- Input the number of nodes: 4 Input data for node 1 : 10 Input data for node 2 : 20 Input data for node 3 : 30 Input data for node 4 : 40 Return data entered in the list as an array: 10 20 30 40 ... Write a C program to convert a singly linked list into a dynamically allocated array.
Discussions

Need help with converting an array to a list in C#` - Questions & Answers - Unity Discussions
Okay, I’m bringing in xml data, so I assume that has to be done with an array, or at least is done that way in this example: http://wiki.unity3d.com/index.php?title=Saving_and_Loading_Data:_XmlSerializer . Now since that part works, I don’t want to mess around with it unless I have to, ... More on discussions.unity.com
🌐 discussions.unity.com
0
March 9, 2014
How do I convert a Python list into a C array by using ctypes? - Stack Overflow
How can I call the c_function with a contiguous list of elements in x? I tried to cast x to a c_void_p, but that didn't work. ... The C code clearly wants the address of an array. More on stackoverflow.com
🌐 stackoverflow.com
c# - Converting a list to an array with ToArray() - Stack Overflow
I've created a class called listItem and the following list: List myList = new List (); At some point in my code, I want to convert it to an array, thereby using: More on stackoverflow.com
🌐 stackoverflow.com
Convert list to array C# - Stack Overflow
Could you tell me how can I put elements from a list to twodimensional array in C#? More on stackoverflow.com
🌐 stackoverflow.com
🌐
arrayThis
arraythis.com
Online array converter; convert your text list to array | arrayThis
In the need to optimize your list (remove duplicates, empty lines, sort, prefix and suffix, etc.) use KitTxt before.
🌐
Unity
discussions.unity.com › archived forums › questions & answers
Need help with converting an array to a list in C#` - Questions & Answers - Unity Discussions
March 9, 2014 - Okay, I’m bringing in xml data, so I assume that has to be done with an array, or at least is done that way in this example: http://wiki.unity3d.com/index.php?title=Saving_and_Loading_Data:_XmlSerializer . Now since that part works, I don’t want to mess around with it unless I have to, I need to convert deck information brought in from an array into a list, so it’s easier to manipulate.
🌐
Dot Net Perls
dotnetperls.com › convert-list-array
C# - Convert List to Array - Dot Net Perls
It is possible to convert arrays to Lists (and lists to arrays) with this code. We cannot just assign one to the other.
🌐
Educative
educative.io › answers › how-to-convert-a-c-sharp-list-to-an-array
How to convert a C# list to an Array
The List<T> class in the System.Collections.Generic namespace provides the ToArray() method, which can be used to convert a C# List to an Array.
🌐
C# Corner
c-sharpcorner.com › UploadFile › c25b6d › conversion-from-list-to-array-and-vice-versa
How to convert C# List to an array?
September 8, 2023 - namespace ConsoleApplication8 { class Program { static void Main(string[] args) { //creation of list<> List<int> number = new List<int>(); //add the elements in the list number.Add(10); number.Add(20); number.Add(15); number.Add(25); number.Add(30); number.Add(35); number.Add(40); number.Add(45); //creation of an array int[] a = number.ToArray(); //display the array element Console.WriteLine("the array elements are:"); foreach (int i in a) { Console.WriteLine(i); } } } } ... In this example, we see how to convert an array of any number of elements to a List that has the same type of elements.
Find elsewhere
🌐
Makolyte
makolyte.com › csharp-convert-a-list-to-an-array
C# - Convert list to array | makolyte
January 25, 2025 - The simplest way to convert a list to an array is to use the List.ToArray() method: This outputs the following: Internally, the List class stores elements in…
🌐
C# Corner
c-sharpcorner.com › home › technologies › how do i › how to convert an array to a list in c#?
How to Convert an Array to a List in C#?
October 10, 2023 - There are multiple ways to convert an array to a list in C#. One method is using a List.AddRange method that takes an array as input and adds all array items to a List.
🌐
YouTube
youtube.com › watch
Convert an Array into a Linked List - C Linked List Tutorial - YouTube
This tutorial will explain how to convert an array into a linked list.
Published: August 21, 2019
🌐
YouTube
youtube.com › watch
C# - Convert list to array - YouTube
The video shows the code you can use to convert a list to an array.C# - How to convert a list to array
Published: September 28, 2015
🌐
Techie Delight
techiedelight.com › home › c++ › convert a list to an array in c++
Convert a list to an array in C++ | Techie Delight
July 7, 2026 - This post will discuss how to convert a list to an array in C++... A simple solution is to use a range-based for-loop to traverse the list and, one by one, add each element at the next available index in the array.
🌐
GeeksforGeeks
geeksforgeeks.org › c# › c-sharp-how-to-convert-an-arraylist-to-array
C# | How to convert an ArrayList to Array - GeeksforGeeks
July 11, 2025 - Example: In the below program, mylist is the ArrayList and we added 7 items to it which are the name of weekdays. Then we are creating an object array obj1 and using ToArray method with mylist we will assign the Arraylist elements to the object array. Finally, using foreach loop you can print the required converted array.
🌐
McNeel Forum
discourse.mcneel.com › grasshopper
C# array to list - Grasshopper - McNeel Forum
September 14, 2020 - I do not want to make a loop to go from array to list. ToList() does not work new List (myArray) does not work List list = myArray.ToList (); does not work ConvertAll is not clear to me Do you know what the right code is? question8.gh (4.9 KB)
🌐
Programiz
programiz.com › java-programming › examples › convert-list-array
Java Program to Convert a List to Array and Vice Versa | Programiz
March 14, 2024 - Python online compiler JavaScript online compiler SQL online compiler Java online compiler HTML online compiler C online compiler C++ online compiler C# online compiler PHP online compiler Swift online compiler Kotlin online compiler TypeScript online compiler Go online compiler Rust online compiler Scala online compiler Dart online compiler R online compiler Ruby online compiler · Access elements from a LinkedList. ... Remove elements from the LinkedList. ... In this example, we will learn to convert a Java list to an array and vice versa.