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 8258937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:43:08+00:00 2026-06-08T02:43:08+00:00

#define L 1 #define M L+1 int main(void){ int N=L*M*2; char s [N]={‘1′,’2’}; printf(%d,

  • 0
#define L 1
#define M L+1

int main(void){

    int N=L*M*2;
    char s [N]={'1','2'};
    printf("%d", sizeof(s));

    return 1;   
}

Why does the above code cannot be compiled? The compiler of Eclipse says two things:

  1. Variable-sized object may not be initialized: Is because the definition of N with M and L at the macro or is it because I can’t initialize an array with type arr[x] where x is variable under any circumstances?
  2. excess elements in array initializer– What does it mean?
  • 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-06-08T02:43:10+00:00Added an answer on June 8, 2026 at 2:43 am

    because I can’t initialize an array with type arr[x] where x is variable?

    Indeed, pre-C99, the array size must be a constant expression. In C99, this has been relaxed with variable-length arrays.

    (This is is nothing to do with macros.)

    excess elements in array initializer- What does it mean?

    Fix the first problem, and this should go away.

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

Sidebar

Related Questions

#include<conio.h> #include<stdio.h> #define abc 7 int main() { int abc=1; printf(%d,abc); getch(); return 0;
#include <stdio.h> #include <ctype.h> #define STRING_LEN 500 void stripspaces(char, char, char); int main(void) {
Following are one code snippet #define T 0xFF using namespace std; int main(void) {
#include vss.h #include vswriter.h #include <VsBackup.h> #include <stdio.h> #define CHECK_PRINT(result) printf(%s\n,result==S_OK?S_OK:error) int main(int argc,
#include<stdio.h> #define N (sizeof(array) / sizeof(array[0])) main() { int array[5]={1,2,3,4,5}; int d; for(d=-1;d <=
Suppose I define a union like this: #include <stdio.h> int main() { union u
#include <iostream> #include <cmath> #define max(x,y) (x)>(y)? (x): (y) int main() { int i
I have the next scenario: I define an int[][] variable in my main class.
I have 4 files: shared.h main.cpp something.h something.cpp shared.h: #ifndef SHARED_H #define SHARED_H int*
The following code works fine #define open { #define close } #include<stdio.h> #define 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.