How do I declare a 2d array in C using new

0 votes

How do I declare a two-dimensional array using new?

For example, for a "typical" array, I would:     

int* ary = new int[Size]

but

int** ary = new int[sizeY][sizeX]

a) doesn't work/compile and b) doesn't accomplish what:

int ary[sizeY][sizeX] 

does

Jul 15, 2022 in C++ by Nicholas
• 7,760 points
488 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In C++

0 votes
1 answer

How do I reverse a C++ vector?

The algorithm header has a method std::reverse for this purpose. #include <vector> #include <algorithm> int main() { std::vector<int> ...READ MORE

answered Jun 27, 2022 in C++ by Damon
• 4,960 points
743 views
0 votes
0 answers

How to declare an array of strings in C++?

I am trying to iterate over all ...READ MORE

Jul 26, 2022 in C++ by Nicholas
• 7,760 points
542 views
0 votes
1 answer

How do I use 'strlen()' on a C++ string

In C++, there are two standard methods for storing strings.  In this scenario, you specify an array of characters, and 0 signifies the end of the string. #include <cstring> char str[500] = "Hello"; // How ever ...READ MORE

answered Aug 2, 2022 in C++ by Damon
• 4,960 points
1,195 views
0 votes
0 answers

How do you open a file in C++?

I want to open a file in ...READ MORE

Aug 8, 2022 in C++ by Nicholas
• 7,760 points
555 views
0 votes
1 answer

How to use std::sort to sort an array in C++

We receive std::begin and std::end in C++0x/11, which are overloaded for arrays: #include <algorithm> int main(){ int v[2000]; ...READ MORE

answered Jun 1, 2022 in C++ by Damon
• 4,960 points
1,137 views
0 votes
1 answer

How do i apply lower_bound to a range of unsorted vector elements?

What's the point of sorting your array? ...READ MORE

answered Jun 15, 2022 in C++ by Damon
• 4,960 points
1,764 views
0 votes
1 answer

Passing a 2D array to a C++ function

There are three ways to pass a ...READ MORE

answered Aug 2, 2022 in C++ by Damon
• 4,960 points
30,412 views
0 votes
1 answer

How to check if array is multidimensional or not?

Since the 'second dimension' could be just ...READ MORE

answered Nov 5, 2018 in Others by DataKing99
• 8,250 points
5,946 views
0 votes
0 answers

How do I determine the size of my array in C?

How do I determine the size of ...READ MORE

May 1, 2022 in Others by Kichu
• 19,040 points
455 views
0 votes
0 answers

How can I create a two dimensional array in JavaScript?

Is it possible to create a two-dimensional ...READ MORE

May 9, 2022 in Java-Script by Kichu
• 19,040 points
755 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP