why a[i] is not compiling . array compilation error

This is a discussion on why a[i] is not compiling . array compilation error within the C Programming forums, part of the General Programming Boards category; Originally Posted by laserlight Unless you are able to make use of the variable length array feature introduced in the ...

  1. #16
    kotin
    Join Date
    Oct 2009
    Posts
    132
    Quote Originally Posted by laserlight View Post
    Unless you are able to make use of the variable length array feature introduced in the 1999 edition of the C standard, your array a must have a fixed size known at compile time, so j cannot be a variable.
    Hi light,

    I did not get properlly "Unless you are able to make use of the variable length array feature introduced in the 1999 edition of the C standard".

    please can you tell once this?

    Regards
    NKRao

  2. #17
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by nkrao123@gmail. View Post
    please can you tell once this?
    I think we already have at least two or three times. The "variable length" feature in c99 -- the 1999 ANSI C standard -- allows you to declare an array with a variable length.

    However, no C standard allows you to initialize such an object with values. You cannot do that, period, end of story.

    Here are two declarations:
    Code:
    int x;
    int array[n];
    These variables have not been initialized; they could have any value in them.

    Code:
    x = 12;
    Now x has been initialized. It could have been initialized in the declaration:

    Code:
    int x = 12;
    An array of fixed length can also be initialized in its declaration:
    Code:
    int array[3] = {4, 5, 666};
    However, you cannot:
    1) initialize an array after its declaration; you must assign to individual elements.*
    2) initialize a variable length array, such as "int array[n]"

    Read posts #14 and #15 again if you still do not understand what this means. If you want to put values into a variable length array, you have to do so after the declaration.

    * actually you can set more than one at time with memset().
    Last edited by MK27; 09-06-2011 at 06:40 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #18
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by nkrao123@gmail. View Post
    Light used that word as it should. I thought my compiler may have that features. That why i tried. Now i understand that my compilr does not supporting this feature
    Hint: People are sending messages with more than one line and more than code samples... READ what they are sending to you!

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. compilation error on array assignment.
    By sanddune008 in forum C Programming
    Replies: 2
    Last Post: 07-26-2010, 03:50 AM
  2. error: was not declared in this scope compilation error
    By i_r_tomash in forum C Programming
    Replies: 2
    Last Post: 05-27-2010, 08:44 AM
  3. Compilation Error. Need help
    By CS_Student8337 in forum C Programming
    Replies: 4
    Last Post: 02-11-2009, 10:57 AM
  4. help about compilation error
    By netwizio in forum Linux Programming
    Replies: 2
    Last Post: 01-16-2004, 06:22 PM
  5. compilation error
    By blue_gene in forum C++ Programming
    Replies: 1
    Last Post: 12-28-2003, 12:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21