By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,276 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,276 IT Pros & Developers. It's quick & easy.

Cannot allocate array

P: n/a
I get the following error when I try to allocate the below code:

cannot allocate an array of constant size 0

int main() {
int dim = 3;
int b[dim][dim];

return 0;
}
What am I doing wrong?
Aug 1 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
saneman wrote:
I get the following error when I try to allocate the below code:

cannot allocate an array of constant size 0

int main() {
int dim = 3;
int b[dim][dim];

return 0;
}
What am I doing wrong?
Not using a C99 compiler.

To be legal c++, you should uee a const:

const size_t dim = 3;

--
Ian Collins.
Aug 1 '08 #2

P: n/a
Ian Collins wrote:
saneman wrote:
>I get the following error when I try to allocate the below code:

cannot allocate an array of constant size 0

int main() {
int dim = 3;
int b[dim][dim];

return 0;
}
What am I doing wrong?
Not using a C99 compiler.

To be legal c++, you should uee a const:

const size_t dim = 3;
const int dim = 3; would be fine too.

Aug 2 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.