472,982 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 software developers and data experts.

Cannot allocate array

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
2 1659
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: overbored | last post by:
I can do this: int asdf; int* zxcv = asdf; but not this: int asdf; int** zxcv = asdf;
3
by: Richard Cavell | last post by:
#include <gmp.h> mpz_t* p_mympz = new mpz_t; error: cannot convert '__mpz_struct*' to '__mpz_struct (*)' in initialization 1. What does that mean? 2. Given that mpz_t doesn't have a...
3
by: Simon | last post by:
Hello everybody, I've got a problem. I'm trying to allocate an array inside a function with Parameter int n: main(){ int i; .... i = strlen(ch); array(i); ....
6
by: Rene | last post by:
Could anyone tell me what is the reason I can't initialize the members of a struct like this: public struct SomeStruct { public int uno = 1; // Error public int dos = 2; // Error public...
12
by: paul | last post by:
Hi everyone, I'm debugging an FFT routine and it has thrown up a perplexing error which I cannot trace. Cannot anyone help? I've included the relevant code below with comments: rlft3(data_in1,...
3
by: valerio | last post by:
Hello all I would like to dinamically allocate an array of array of structures. To explain this: struct file{ char* fileName,int inode) myfiles; struct file{ char* fileName,int inode) mydirs; ...
13
by: hn.ft.pris | last post by:
Hi: I have the following simple program: #include<iostream> using namespace std; int main(int argc, char* argv){ const double L = 1.234; const int T = static_cast<const int>(L); int arr;
5
by: Siegfried Heintze | last post by:
On line 5 of the program below I get the error message in the subject line. (1) How may I correct it? (2) How may I enhance my Arr class to work with a foreach statement? (3) In C++ I can pass...
3
by: Samant.Trupti | last post by:
HI, I want to dynamically allocate array variable of type LPWSTR. Code looks like this... main() { LPWSTR *wstr; int count = Foo (wstr); for (int i = 0; i < count; i++) //print each...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.