float detrminant(float[][], float);
I'm using python.
float detrminant(float[][], float);
I'm using python.
I'm just trying to find the inverse of a matrix and before it even runs the code it says that I have an invalid syntax with this line.
Code:#include<stdio.h> #include<math.h> float detrminant(float[][], float); void cofactors(float[][], float); void trans(float[][], float[][], float); main() {
Only the left-most [] can be empty.
All the others need the actual size of the corresponding minor dimension of the array you want to pass in.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
so by putting
it should workCode:#include<stdio.h> #include<math.h> float detrminant (float[][25], float); void cofactors(float[][], float); void trans(float[][], float[][], float); main() {
They are empty because the user needs to define the size of the matrix
If this is true then why not have the user input the size and then pass this data to the function as an argument into the parameter? You may be confusing C syntax with Python (never used it, so don't know for sure). In this concept, you would not have empty indexes for the array within the parameter list as the value is already present.
Double Helix STL
> They are empty because the user needs to define the size of the matrix
How?
If you're using C99, then this would work for arrays that will fit on the stack.
But if you want really large arrays, then using malloc is your only choice, and the [][] syntax no longer applies.Code:#include <stdio.h> #include <string.h> void foo ( int size, char arr[][size] ) { for ( int i = 0 ; i < size ; i++ ) { printf("%s\n", arr[i] ); } } int main ( ) { int size = 10; // get this from the user char arr[size][size]; for ( int i = 0 ; i < size ; i++ ) { sprintf(arr[i],"Line %d",i); } foo(size,arr); return 0; }
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.