LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


LinkBack Search this Thread
Old 12-26-2003, 02:51 PM   #1
Registered: Nov 2003
Posts: 77

Rep: Reputation: 15
Is this ansi-c compliant?


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


Last edited by xailer; 12-26-2003 at 02:56 PM.
Old 12-26-2003, 03:43 PM   #2
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
why dont you just compile with gcc and use -ansi and find out?
Old 12-26-2003, 06:26 PM   #3
Registered: Nov 2003
Posts: 77

Original Poster
Rep: Reputation: 15
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
Old 12-26-2003, 08:00 PM   #4
Registered: Dec 2001
Location: Adelaide , South Australia
Distribution: redhat 7.2, Debian , OpenBSD
Posts: 123

Rep: Reputation: 15
this is is an old style if i remember correctly
Old 12-26-2003, 08:48 PM   #5
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
YES that is compliant and YES you can rely on gcc to tell you.
Old 12-26-2003, 08:49 PM   #6
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
and "No, it ain't" isn't "grammatically compliant".


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux on a LEAP compliant network zombiedeth Linux - Software 1 09-14-2005 01:45 PM
802.11a EEEI Compliant mst700 Linux - Wireless Networking 4 06-07-2005 02:32 PM
how a new distro is GPLed compliant? nazib Linux - General 1 03-01-2005 05:50 AM
c programming compliant with posix ---HELP! v333k Programming 4 02-28-2005 03:08 PM
HID compliant gamepad bobbens Linux - Hardware 6 10-27-2004 11:04 AM

All times are GMT -5. The time now is 01:29 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration