permaculture playing cards
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
JavaRanch » Java Forums » Languages » C / C++
Bookmark "ArrayList equivalent in C?" Watch "ArrayList equivalent in C?" New topic

ArrayList equivalent in C?

Jack Drowder

Joined: Oct 01, 2012
Posts: 10
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?

K. Tsang

Joined: Sep 13, 2007
Posts: 3132

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 OCPJP7 OCPWCD5 OCPBCD5 OCPWSD5 OCMJEA5 part 1 part 2/3
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

C or C++? if the latter, the vector class in the STL may help. If you are talking straight 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:
subject: ArrayList equivalent in C?
It's not a secret anymore!