Get your CodeRanch badge!*
The moose likes C / C++ and the fly likes ArrayList equivalent in C? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "ArrayList equivalent in C?" Watch "ArrayList equivalent in C?" New topic
Author

ArrayList equivalent in C?

Jack Drowder
Greenhorn

Joined: Oct 01, 2012
Posts: 5
Hi guys,

I'm making a simple calculator program in C. It's supposed to be able to save loads of (floating point) numbers in an array and the array is supposed to expand to accommodate the new numbers. As I've been doing Java for quite some time now, I know that an ArrayList would be useful in this situation, but is there something similar to it in C?

Thanks!
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1956
    
    7

Not that I know of. You most likely need to define your own data structure as an array list. The link here should give you some insight.

And welcome to the Ranch.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10906
    
  12

C or C++? if the latter, the vector class in the STL may help. If you are talking straight C...you may have to roll your own, as the previous poster said.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList equivalent in C?
 
Similar Threads
processing with arrays
Need help with sorting an array
Constructing an array.
Resetting the array size
how to increase the size of an array