allocate double dimension array in C

S

swesoc

Hello Friends,

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

Kai-Uwe Bux

swesoc said:
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
 
N

Niklas Norrthon

swesoc said:
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
*/
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top