So I'm new to C and I'm having a problem with arrays. In my program, I let the user enter up to 5000 numerical values. I have the program set up in a menu system, so each time, the user can chose to enter a new number, or view what they have already entered. How would I go about adding a new element to the array each time the user enters a new number?

You don't actually add new elements -- just keep track of the next unused element then increment the counter once that element has been filled. Static arrays can not be expanded or contracted, so declare an array of integers of size 5000 elements, then declare an int counter which keeps track of the next unused element, and should initially contain 0.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.