Are the following array declarations valid, if not why?: "i'm confused!"
const int SIZE=4;
void main()
{
int a= {0,2,4,6};
static int b={0,2,4,6,8};
int x[SIZE-5];
int d[SIZE*2];
. . .
. . .
}
Faramba
0
Newbie Poster
Recommended Answers
Jump to Post>>static int b={0,2,4,6,8};
SIZE = 4; b has 5 elements - not good>>int x[SIZE-5];
SIZE-5 = -1. You cannot declare an array with negative dimention.Also, int main () , not void main ().
And, for defining the size of an array, I prefer #define SIZE X …
All 3 Replies
frrossk
2
Posting Whiz in Training
jwenting
1,889
duckman
Team Colleague
Richard Wong
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.