#include"stdafx.h"
#include<cstdlib>
#include<iostream>
usingnamespace std;
int tmain(int argc, _TCHAR* argv[])
{
// Let's Declare Variables
int Num_Pegs; // Total number of pegs to a side
int Hold_Und; // Hold underscore location
// User Enters Number of Pegs
cout <<"Enter Number of Pegs:";
cin >>Num_Pegs;
// Array to create a board
char board[Num_Pegs * 2];
// Fill Array
for (int b = 0; b < Num_Pegs; b++)
For some reason, I keep getting an error from VC++ compiler saying "Expected a constant expression"? Also cannot allocate "size 0 array"?
When I run this program (Full Code) in DevC+, I have no problem!? But of course it has to be done in VC++ WIN32. Any help would be great!
spankyg
0
Light Poster
Recommended Answers
Jump to Post
char board[Num_Pegs * 2];
is not valid c++. it is not even valid c, though g++ does allow it (unless you use the switch -std=c++98). standard c++ requires that the size of an array with an automatic or static storage duration should be a constant known at compile time. …
Jump to Post>I just think it is funny that Dev(Bloodshed) finds it O.K., but VC2005 wont allow it?
Your code is wrong, and one of the compilers you use happens to allow the wrong code while the other correctly bitches at you. That's typical behavior when you step out of the realm …
All 7 Replies
spankyg
0
Light Poster
vijayan121
1,152
Posting Virtuoso
jtorjo
0
Newbie Poster
spankyg
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
ShawnCplus
456
Code Monkey
Team Colleague
spankyg
0
Light 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.