LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 10-17-2009, 06:13 PM   #1
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
is this ansi C?


first this is not homework just had a personal question
is this code ANSI C?
Code:
#undef DOS_WIN
#define UNIX
int main(){
void print_hello_world(){
printf("Hello world");
#ifdef UNIX
printf("\n");
#endif
#ifdef DOS_WIN
printf("\r\n");
#endif
}
print_hello_world();
}
 
Old 10-17-2009, 06:46 PM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
No, you can't have nested function definitions. If you specify '-pedantic', gcc will give you the appropriate warning. (Incidentally, you also need a prototype for the printf).

Last edited by neonsignal; 10-17-2009 at 06:47 PM.
 
Old 10-17-2009, 06:59 PM   #3
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Original Poster
Rep: Reputation: 231Reputation: 231Reputation: 231
thats what i thought
 
  


Reply

Tags
standard



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
3 Questions about ANSI-C SpLaSh212 Programming 6 01-03-2009 10:28 AM
How to read F1,F2 in Ansi C? john.daker Programming 4 11-05-2008 09:36 AM
Ansi Telnet thebutler4 Linux - Software 1 05-25-2004 12:58 PM
Is this ansi-c compliant? xailer Programming 5 12-26-2003 08:49 PM
ANSI C Manual rajaram Programming 6 01-05-2002 07:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:00 PM.

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