i found following code to create a two dimensional array at run time if one of the dimension is known..
char (*c)[5];
c=new char[n][5];
first line is pointer to an array of 5 integers but i couldnt undesratnd the second step.
i found following code to create a two dimensional array at run time if one of the dimension is known..
char (*c)[5];
c=new char[n][5];
first line is pointer to an array of 5 integers but i couldnt undesratnd the second step.
first line is pointer to an array of 5 integers
Those are char pointers, not integers.
The first line declares an array of unknown number of pointers, each pointer points to a memory block of 5 bytes.
The second line allocates a single block of memory with size n*5. This is much faster and more efficient than allocating each of the n pointers individually.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.