Note that there are some explanatory texts on larger screens.

plurals
  1. POInitialising float matrix inside function
    text
    copied!<p>I got this problem when trying to initialize global c++ matrix(2D array) inside a function:</p> <p>here is what I'm doing</p> <pre><code>#include &lt;iostream&gt; #include &lt;math.h&gt; #include &lt;Windows.h&gt; using namespace std; float matrix[5][5]; void setIR(){ matrix[5][5]= { { 17.2, 22.75, 2.5, -9.15, 0.2}, { 22.75, 145.5, 9.25, 20.75, 5.25 }, { 2.5, 9.25, 76.5, -15.5, -6.0 }, { -9.15, 20.75, -15.5, 37.3, -25.65 }, { 0.2, 5.25, -6.0, -25.65, 41.2 } }; int main(){ //rest of the code ...... } </code></pre> <p>I'm getting only bunch of </p> <pre><code>1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(46): error C2059: syntax error : '{' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(46): error C2143: syntax error : missing ';' before '{' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(47): error C2143: syntax error : missing ';' before '}' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(47): error C2143: syntax error : missing ';' before ',' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(48): error C2143: syntax error : missing ';' before '{' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(48): error C2143: syntax error : missing ';' before '}' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(48): error C2143: syntax error : missing ';' before ',' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(49): error C2143: syntax error : missing ';' before '{' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(49): error C2143: syntax error : missing ';' before '}' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(49): error C2143: syntax error : missing ';' before ',' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(50): error C2143: syntax error : missing ';' before '{' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(50): error C2143: syntax error : missing ';' before '}' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(50): error C2143: syntax error : missing ';' before ',' 1&gt;c:\users\apple\documents\visual studio 2010\projects\jcb\jcb\jcbPIO.cpp(51): error C2143: syntax error : missing ';' before '{' 1&gt;c:\users\apple\documents\visual studio2010\projects\jcb\jcb\jcbPIO.cpp(51): error C2143: syntax error : missing ';' before '}' </code></pre> <p>I'm doing something wrong or C++ limitation ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload