How do I add/delete elements from an array?
I need to create a program that uses an array of structs.
I should be able to add and delete elements.
I also need to be able to search the array for a specific string.
How do I do that?
I don't know how to add or delete elements from an array.
I had always regarded an array's length as static.
also, how do i set up a search for an element within an array of structs?
If this were java, it would be different (yay, arraylist!) - but it's not...So i'm quite confused.
Any help would be fantastic.
[569 byte] By [
naazrael] at [2007-11-11 8:47:26]

# 1 Re: How do I add/delete elements from an array?
Arrays, that is real arrays, are static in C and C++, which means that you can't change their size at runtime. You may replace elements, as long as you don't step out of the array's boundaries. If you need an array like datatype which can be extended and shrunk at runtime, use std::vector. In fact, use it whenever you can;) It's so much better than anything you've seen in Java, not to put too fine a point on it.
Danny at 2007-11-11 21:01:00 >

# 2 Re: How do I add/delete elements from an array?
yeah, i've seen that std::vector thing thrown around a bit.
How does that work?
I don't know much about it.
# 3 Re: How do I add/delete elements from an array?
It is a class that makes arrays into objects, basically. Just like int, it is part of the language, look in your help files for examples and usage.
jonnin at 2007-11-11 21:03:05 >
