Programming Questions

  • Newest
  • Popular Tags
  • Ask Question
  • Find size of matrix in C++
    Hey, does someone know a easy to use library for C++ including a feature to find the size of matrixes easily. Thanks!
    TheErebos01 posted this question on 12/12/18 | matrix, library, cpp
    Answers
  • +
  • 0
  • -
  • #include <iostream> using namespace std; int main() { int matrix [3][2]; int rows=sizeof( matrix )/sizeof( matrix[0] );/* the first part is to count how many bytes should occupy in this (2D array) , and the second is just how many bytes in the first row , if you divided them you'll get the number of rows of course */ int columns =sizeof( matrix[0] )/sizeof( matrix[0][0] );/* the first part is just the same as before but you should divided it by the number of the bytes of each location "ex: the first location" , to get the number of columns in the matrix */ // there is many ways you can express the same idea , good luck . return 0; }
    Log in to write an answer.