About 12,700,000 results
Open links in new tab
  1. c++ - How to pass two dimensional array of an unknown size

    Apr 16, 2012 · Multi-dimensional arrays are not very well supported by the built-in components of C and C++. You can pass an N -dimension array only when you know N-1 dimensions at …

  2. How to Create a 2D Array of a Specific Size and Value in C++?

    Mar 12, 2024 · Syntax to Create 2D Array. The syntax for creating and initializing a 2D array in C++ is as follows: datatype array_name[row_size][column_size]; datatype: Specifies the type …

  3. 2D Array as Parameter w/ Unknown Size - C++ Forum - C++ Users

    Jan 24, 2012 · Is it possible to pass 2D arrays as a parameter without knowing the size? The effect I'm trying to get is: void print( double a[][], int row, int col){ //Print 2D array}

  4. [C++] how to pass a multidimensional array of unknown size ... - Reddit

    TL;DR: how do I pass a multidimensional array into a function when I don't know the size of any dimension? SOLVED! std::vector<std::vector<int>> foos(10, std::vector<int>(20)); foos[2][4] = 42;

  5. How to initialize an array whose size is initially unknown?

    Mar 16, 2014 · Size of dynamically created array on the stack must be known at compile time. You can either use new: const char* pArray = new char[x]; ... delete[] pArray; or better to use …

  6. Declare 2D Array in C++: A Quick Guide - cppscripts.com

    Syntax of Declaring a 2D Array in C++. To declare a 2D array in C++, the syntax is straightforward. The general format is: dataType arrayName[rows][columns]; Here, `dataType` …

  7. Initializing arrays of a yet unknown size in a class : r/cpp ... - Reddit

    Feb 16, 2022 · std::array requires the size to be known at compile time, which in your case won't work. What you can do is map the 2d array to a 1d array (size = width * height), add some …

  8. How to declare a 2D array dynamically in C++ using new operator

    Sep 14, 2022 · Problem: Given a 2D array, the task is to dynamically allocate memory for a 2D array using new in C++. Solution: Following 2D array is declared with 3 rows and 4 columns …

  9. Declaring Multidimensional Array of Unknown Size - C++ Users

    Mar 29, 2019 · You can use std::vectors for this. A "vector of vectors" is equivalent to an "array of arrays", which is what a 2D array essentially is.

  10. Passing a 2D array of unknown size to a function C++

    Dec 15, 2015 · You cannot safely pass a dynamically allocated 2D array in C++ into a function because you always have to know at least one dimension at compile time. I could point over at …

Refresh