Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 642085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:07:59+00:00 2026-05-13T21:07:59+00:00

According to my memory the following piece of code should compile fine on C++

  • 0

According to my memory the following piece of code should compile fine on C++ but not in C.
Only problem is how to test it? It compiled fine with g++ and also with gcc. I’m assuming that g++ is C++ compiler and gcc is C compiler. I’ve tried it with mingw under Windows. Am I correct? if not then how to compile it using C compiler.

int main() {
 const int i = 1;
 const int j = 2;
 const int k = 3;

 int array[i + j + k];
 return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:07:59+00:00Added an answer on May 13, 2026 at 9:07 pm

    No, that will compile in C99, which has support for variable length arrays. To get strict C89 behavior, try compiling with:

    gcc -std=c89 -pedantic-errors
    

    That gives:

    error: ISO C90 forbids variable length array ‘array’
    

    c89 means use C89, pedantic-errors means error on non-C89 code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would the following piece of code create a memory leak. According to the jQuery
I am not sure if the following code is safe from memory leak. #ifndef
I have a process holding 130MB of memory according to task manager, with only
I am releasing things but the memory seems to still be there according to
I'm trying input validation in the following piece of code: typedef unsigned long DATATYPE;
Consider following piece of code void foo( bool forwad ) { vector<MyObject>::iterator it, end_it;
Consider the following code: class Test() { public: Test() { memset( buffer, 0, sizeof(
According to Msdn : Memory-mapped files enable programmers to work with extremely large files
According to the UIImage documentation : In low-memory situations, image data may be purged
According to the C++11 standard, is the following program well-formed and portable C++? int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.