Thread: dynamic array

  1. #1
    Registered User
    Join Date
    Aug 2005

    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
    The edge of the known universe
    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
    >> what is the code for dynamic array?

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

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

    *** sorry just anticipating his next question.

    bah i might as well answer it then.

    make sure to include

    #include <vector>

    a couple types of vector would be

    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