cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : General C++ Programming : array bound is not an integer constant
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programm...
Articles
Lounge
Jobs

-

post  array bound is not an integer constant

abhikant08 (5)
hi, i have to input and then display a matrix using functions. the problem is that i have to enter the bounds of the matrix from the user.i tried this by two ways but none of them worked. 1-i made the array global but declaring a[m][n] in global variables ,i got this error " array bound is not an integer constant"
so i thought of entering the bounds of the array in main fucntion and then passing the array to the display function, which made me define the function as
void dispmatrix(int a[][n],int m,int n)

but this also gives me the same error
|
Zhuge (110)
You cannot declare an array with variable size unless you use the new keyword.
See: http://www.cplusplus.com/doc/tutorial/dynamic.html
|
buffbill (57)
It may be better to use a vector which in many ways is similar to an array but does not need its size specified at compile time. It keeps track of its element number as incremented and decremented. The <vector> header file is required.
|
Faldrax (322)
See http://www.cplusplus.com/reference/stl/ for docs on the various standard containers (which include vector).
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2009 - All rights reserved - v2.2
Spotted an error? contact us