0
I want some help with dynamic arrays in C🥺
In 22nd line of my code, I used an array to store all the factors of a number which is of type long int. We all know that the number of factors of a number is variable as it's dependent on the number. Is there anything I can do to optimize my code? I imagine something as an array with initially of one length of type long int, and gets bigger automatically when I add elements. https://code.sololearn.com/cBYJYLKnYpHE/?ref=app
4 ответов
+ 1
I can't see any dynamic array in your program.
What is it that you need help with ?
Also it's better to provide some description about the problem and the program in your question description to help others to understand your problem and in turn help you solve it.
0
You can use malloc and realloc for dynamically allocating memory for an array. It might slow your program down a bit but would improve memory management.
0
Thoq! Oh okay noted 📝📝📝
0
Arsenic I didn't use any dynamic arrays in my program, rather I used a large array by guessing the upper limit of the number of elements. If you read my program and my description of my question, you'll know what I'm talking about. Thank you for your consideration