LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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
 
LinkBack 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,208

Rep: Reputation: 147Reputation: 147
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 Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
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,208

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


Reply

Tags
standard


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
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


All times are GMT -5. The time now is 06:20 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration