Thread: dynamic array

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    1

    Unhappy dynamic array

    im new to this so,
    what is the code for dynamic array?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    See this?
    User CP FAQ Members List Calendar Search New Posts Mark Forums Read Open Buddy List Log Out

    Good, now click the "search", and type in "dynamic array"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> what is the code for dynamic array?

    In C++, you use a vector for dynamic arrays.

  4. #4
    Banned
    Join Date
    Jun 2005
    Posts
    594
    what the code for a vector?

    *** sorry just anticipating his next question.

    edit
    bah i might as well answer it then.


    make sure to include

    #include <vector>


    a couple types of vector would be

    vector<int>
    vector<string> //require string header

    you can also create your own types for it.

    to add element to a vector you can do


    vector<string> vecOFstrings;
    vecOFstrings.push_back("this is a string"); //you can also push_back by a variable


    there are many things you can do just do a search on vectors,
    you can also use iterators they help you from going out
    of the array ( vectors ) bounds.
    Last edited by ILoveVectors; 08-21-2005 at 07:45 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic Array Resizing
    By dld333 in forum C++ Programming
    Replies: 13
    Last Post: 11-04-2005, 12:13 AM
  2. need help with dynamic array syntax
    By soldyne in forum C Programming
    Replies: 3
    Last Post: 10-11-2005, 01:59 PM
  3. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  4. 2D dynamic array problem
    By scsullivan in forum C Programming
    Replies: 3
    Last Post: 12-30-2002, 10:02 PM
  5. Dynamic array allocation and reallocation
    By purple in forum C Programming
    Replies: 13
    Last Post: 08-01-2002, 11:48 AM