allocate double dimension array in C

Discussion in 'C++' started by swesoc, Dec 7, 2005.

  1. swesoc

    swesoc Guest

    Hello Friends,

    How do i allocate menory for a double dimension array in 'C' for
    example for char **var
     
    swesoc, Dec 7, 2005
    #1
    1. Advertising

  2. swesoc

    Kai-Uwe Bux Guest

    swesoc wrote:

    > How do i allocate menory for a double dimension array in 'C' for
    > example for char **var


    If you really want C, you are off topic in this group.

    If you meant C++, consider using std::vector< std::string > instead of
    char** and std::vector< std::vector< T > > instread of T**. This will take
    care of memory management for you.


    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Dec 7, 2005
    #2
    1. Advertising

  3. "swesoc" <> writes:

    > Hello Friends,
    >
    > How do i allocate menory for a double dimension array in 'C' for
    > example for char **var


    You ask in comp.lang.c, or even better read a book about the C
    language, and the documentation of malloc.

    In C++ you do:

    #include <vector>
    #include <string>

    using std::vector;
    using std::string;

    int main()
    {
    vector<string> var;
    /* if you want you can preallocate memory with the reserve
    * member functions of vector and string
    */
    }
     
    Niklas Norrthon, Dec 7, 2005
    #3
  4. swesoc

    Axter Guest

    Axter, Dec 7, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shapper

    Array Dimension

    Shapper, Jun 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    483
    =?Utf-8?B?RGF2aWQgQW50b24=?=
    Jun 8, 2005
  2. Sydex
    Replies:
    12
    Views:
    6,653
    Victor Bazarov
    Feb 17, 2005
  3. valerio
    Replies:
    3
    Views:
    393
  4. Replies:
    5
    Views:
    454
    James Kanze
    Jun 27, 2008
  5. Luuk
    Replies:
    15
    Views:
    884
    Nobody
    Feb 11, 2010
Loading...

Share This Page