LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Is this ansi-c compliant? (http://www.linuxquestions.org/questions/programming-9/is-this-ansi-c-compliant-129085/)

xailer 12-26-2003 03:51 PM

Is this ansi-c compliant?
 
hi

You can use pointer notation with an array in C:

int X[]={1,2,3};

int Y=*X[1];

But can you also use array notation with pointer(is it ansi c compliant)?

int i=3;

int *X=&i;

X[0]=10; //is this legal?

thank you

bye

infamous41md 12-26-2003 04:43 PM

why dont you just compile with gcc and use -ansi and find out? :D

xailer 12-26-2003 07:26 PM

Is function:

int X(i)
int i;
{
int j=16;
}

ansi c compliant?No,it ain't.But still,using 'cc -ansi X.c' doesn't give me any warnings about it,so I don't know why I should rely on -ansi switch to tell me whether something is ansi c or not

chens_83 12-26-2003 09:00 PM

this is is an old style if i remember correctly

infamous41md 12-26-2003 09:48 PM

YES that is compliant and YES you can rely on gcc to tell you.

infamous41md 12-26-2003 09:49 PM

and "No, it ain't" isn't "grammatically compliant".


All times are GMT -5. The time now is 12:51 PM.