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. Advertisements

  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. Advertisements

  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. Advertisements

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:
    587
    =?Utf-8?B?RGF2aWQgQW50b24=?=
    Jun 8, 2005
  2. Larry Lindsey
    Replies:
    5
    Views:
    715
    Mike Wahler
    Sep 27, 2003
  3. James
    Replies:
    11
    Views:
    95,541
    yousafzai
    Jun 4, 2011
  4. Sydex
    Replies:
    12
    Views:
    7,181
    Victor Bazarov
    Feb 17, 2005
  5. valerio
    Replies:
    3
    Views:
    570
  6. Replies:
    5
    Views:
    620
    James Kanze
    Jun 27, 2008
  7. Luuk
    Replies:
    15
    Views:
    1,117
    Nobody
    Feb 11, 2010
  8. ash4
    Replies:
    0
    Views:
    220
Loading...