Results 1 to 3 of 3

Thread: Dynamica arrays in C

  1. #1
    Salman
    Guest

    Talking Dynamica arrays in C

    hi ppl,
    i know there's a lot of talent out there, so i am challenging UR talent. HA HA HA ....
    is there any way to simulate dynamic arrays in C, or C++.
    i really need that..
    and hay , not the linked lists and other things,,,, some piece of code that can enable me to make dynamic arrays just like i do it in VB.......( who says C language is powerful ).
    Salman.

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    To dynamically allocate an array (at rub time):
    Code:
    int myarray = new int[size];
    To change the array size in runtime use the vector class.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Megatron
    Guest
    The vector can also be used to do preserve the data.
    Code:
    #include <iostream>
    #include <vector>
    using namespace std;
    
    int main()
    {
    	vector<int> myVect;
    	// Append 4 and 5
    	myVect.push_back(4);
    	myVect.push_back(5);
    	// Resize to 20;
    	myVect.resize(20);
    	// Output the ubound
    	cout << myVect.size();
    
    	return 0;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width