About 153,000 results
Open links in new tab
  1. How do I declare a 2d array in C++ using new? - Stack Overflow

    Jun 2, 2009 · std array behaves like normal array in c++, that you define with pointer, for example int* and then: new int[size], or without pointer: int arr[size], but unlike the normal array of the …

  2. c++ - 2D array values - Stack Overflow

    One alternative is to represent your 2D array as a 1D array. This can make element-wise operations more efficient. You should probably wrap it in a class that would also contain width …

  3. Passing a 2D array to a C++ function - Stack Overflow

    Jan 7, 2012 · Note that when calling the function the array's address should be passed process_2d_array_pointer(&a) and not the address of the first element by decay …

  4. c++ - How to implement 2D vector array? - Stack Overflow

    Mar 14, 2012 · This will initialize a 2D vector of rows=row and columns = col with all initial values as 0. No need to initialize and use resize. Since the vector is initialized with size, you can use …

  5. Declaring a pointer to multidimensional array and allocating the …

    Oct 11, 2010 · I suggest using a far simpler method than an array of arrays: #define WIDTH 3 #define HEIGHT 4 int* array = new int[WIDTH*HEIGHT]; int x=1, y=2, cell; cell = …

  6. how to find 2d array size in c++ - Stack Overflow

    Apr 23, 2012 · Only in a scope where the array is declared as elementType Foo[][], if the array has every decayed to a pointer this doesn't work. Which makes it hard to determine the size at …

  7. c++ - How do I pass a reference to a two-dimensional array to a ...

    Thus, doing it with the reference, using sizeof on the parameter sizeof array will yield sizeof(int[board_width][board_height]) (as if you would do it on the argument itself) while doing …

  8. What is the safe way to fill multidimensional array using std::fill?

    The function doesn't know anything about the structure of the 2D array. It just gets a pointer and length. The problem is the compiler knows the structure. And it knows that if you pass a …

  9. Sort a 2D array in C++ using built in functions(or any other …

    Nov 20, 2010 · I have a 2D array like below. ( array[5][2]) 20 11 10 20 39 14 29 15 22 23 after sorting it should be like below. 10 20 20 11 22 23 29 15 39 14 that means the array should be …

  10. C++ 2D array to 1D array - Stack Overflow

    Jun 13, 2014 · I am attempting to convert a 2D array to 1D. I'm extremely new to C/C++ but I think it's very important to learn how to convert a 2D array to 1D.

Refresh