Results 1 to 5 of 5

Thread: Dynamic Array

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024

    Dynamic Array

    I know that this has been asked before, at least by me once, but since the SEARCH DOESNT WORK!!, I cant find it.

    How can you dynamicly create arrays?
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  2. #2
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    How to create a dynamic array in C (Don't know if you can use that...): http://cplus.about.com/cs/advancedc/...namic+Arrays+C
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Code:
    //c++
    int *ar = new int[value];
    delete ar;      
    //c
    char *string;
    string = malloc(value);
    free( string );
    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

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    C and C++ use different methods. If you're using C++, then you want new:
    Code:
    int *piArray = new int[50];
    delete[] piArray;
    C:
    Code:
    int *piArray = (int*)malloc(50 * sizeof(int));
    free(piArray);
    In C++, if you actually want a dynamic array, use the STL vector class.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    Megatron
    Guest
    You could also use a linked list.

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