Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can't create float array with a variable name as size parameter?

807575Nov 15 2008 — edited Nov 18 2008
Hi,

When trying to compile code that users a variable in the array subscript to set the size, CC gives the following error:
Error: An integer constant expression is required within the array subscript operator.
1 Error(s) detected.
The code is as follows:
int main()
{
//blah blah
const int arrSize = numberVariables;
    float tempArr[arrSize];
//blah blah
}
Output from CC -V:
unknown% CC -V
CC: Sun C++ 5.9 SunOS_i386 Patch 124864-01 2007/07/25
Output from uname -a:
unknown% uname -a
SunOS unknown 5.10 Generic_137138-09 i86pc i386 i86pc
Any ideas on why CC is giving that error?

~Slow

Edited by: SlowToady on Nov 15, 2008 8:28 PM

Edited by: SlowToady on Nov 15, 2008 8:36 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 16 2008
Added on Nov 15 2008
14 comments
720 views