1

I have just started to code in c++ and usually I used Emacs on a Linux. I then tried to continue work at home on a Windows using visual studio 2017.
This beginning of a code worked on the Linux but continually gives me the Error " The array type "int [n] [n]" can not be assigned" when used on visual studio and i can not understand why. I want to write a program which will calculate a determiant of a given matrix

#include<iostream>
using namespace std;  
int main(){  
int n;  
int r,s;   


  double w;  
  cout<<"please give the size of the matrix from with the determinant be calculated n=";  
  cin>> n;         //User provides size of array

  double m[n][n];  

  for(int k=0; k<n; k++)   {    
  for(int l=0; l<n; l++)    
     {  
       r=k+1;  
       s=l+1;  
       cout<<"Value of the " <<r<<"x"<<s<<" elemente =";     
  cin>>w;  
  m[k][l]=w;  
         };  

    };  




}

Thank you for your help.

Stefan
  • 11
  • 2
  • 2
    `n` has to be a compile-time constant. It is not. On linux it might have worked because gcc has an extension that makes it sometimes work, but it is not legal C++. Use `std::vector` instead. – nwp Aug 25 '17 at 12:36
  • This `double m[n][n]; ` is not valid C++, it's an extnsion that some compilers support, but not VC++. –  Aug 25 '17 at 12:36
  • This would be allowed in C99, and I guess that's why GCC supports it in C++ as an extension, already supporting it in C as it supports C99. Visual Studio does not claim to support C99, however, and has limited support for this standard. – eepp Aug 25 '17 at 12:40

0 Answers0