in this line
i getCode:printf("%d",mat[index][kndex]);
|36|error: invalid use of array with unspecified bounds|
This is a discussion on why i get this syntax error within the C Programming forums, part of the General Programming Boards category; in this line Code: printf("%d",mat[index][kndex]); i get |36|error: invalid use of array with unspecified bounds|...
in this line
i getCode:printf("%d",mat[index][kndex]);
|36|error: invalid use of array with unspecified bounds|
Perhaps because you put a space between the first dimension, and the second.
Santa will give you a piece of C coal for that one!![]()
![]()
no its not a space because when i tried to delete this space i delete "]"
there is no space between them
Post the smallest and simplest program that demonstrates the error.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
Code:void display(int mat[][],int rows,int cols){ int index,kndex; for (index=0;index<rows;index++){ for (kndex=0;kndex<cols;kndex++){ printf("%d ",mat[index][kndex]); } printf("\n"); } }//end display
So the error is on the line that says
When passing arrays to a function, all dimensions (except possibly the first) must be given in the function declaration.Code:void display(int mat[][],int rows,int cols){
but my matrix size is set by the user.
i cant put numbers in [][]
How are you declaring your matrix then? You may have to do the array indexing "by hand", then.
so in the signature i have to write something like:
Code:void display(int mat[3][4],int rows,int cols){
i dont want to declare it
i want to input a matrix with numbers that the user inputed
Obviously you have to declare any variable you intend to use.
can i build a new matrix
and make reference to the input one?
tried this still not working
Code:void display(int mat[][],int rows,int cols){ int index,kndex; int mat2[rows][cols]; mat2[][]=mat[][]; for (index=0;index<rows;index++){ for (kndex=0;kndex<cols;kndex++){ printf("%d ",mat2[index][kndex]); } printf("\n"); } }//end display
Last edited by transgalactic2; 12-18-2008 at 01:34 PM.
i get a different error
|33|error: syntax error before ']' token|
You still can't pass mat[][] into a function. If you don't know the size of the array, you can only pass it in as a pointer-to-int, not as an array.