Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 26, 2012, 12:31 PM   #1
bftiedt
macrumors member
 
Join Date: Feb 2008
Error Running Hello World

hey guys Im reading The C programming Language and trying to run hello world in xcode and keep running into a problem. The code im using is..
Code:
#include <stdio.h>
library
main ( )

{

   printf ("hello, world/n" ) ;

}
When I click run to compile it in xcode i get an error saying, unknown type name "library". Any ides what im doing wrong here? Thanks

Last edited by maflynn; Mar 26, 2012 at 12:40 PM. Reason: Code Tags please
bftiedt is offline   0 Reply With Quote
Old Mar 26, 2012, 12:37 PM   #2
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by bftiedt View Post
hey guys Im reading The C programming Language and trying to run hello world in xcode and keep running into a problem. The code im using is..

Code:
#include <stdio.h>
library
main ( )

{

   printf ("hello, world/n" ) ;

}
When I click run to compile it in xcode i get an error saying, unknown type name "library". Any ides what im doing wrong here? Thanks
The problem is the word "library". I've hilited it in red.

Do you think you need that word? Why? What did you read that tells you to put it there? Exactly which edition of "The C Programming Language? Which page? What authors (Kernighan & Ritchie)?

In short, please describe how you came to have the word "library" there.
chown33 is offline   0 Reply With Quote
Old Mar 26, 2012, 02:27 PM   #3
bftiedt
Thread Starter
macrumors member
 
Join Date: Feb 2008
After looking at the code again i realized the PDF I have pushed Library into the line of code when it was in fact supposed to be part of another sentence lol . Thanks for the help!
bftiedt is offline   0 Reply With Quote
Old Mar 26, 2012, 03:02 PM   #4
robvas
macrumors 68000
 
Join Date: Mar 2009
Location: USA
Be careful cutting+pasting from PDF's it doesn't work often.
robvas is offline   0 Reply With Quote
Old Mar 26, 2012, 05:00 PM   #5
bftiedt
Thread Starter
macrumors member
 
Join Date: Feb 2008
I was actually typing it out ( I think its easier to remember when actually typing) it just put library right into the line of code so it confused me quite a bit.
bftiedt is offline   0 Reply With Quote
Old Mar 26, 2012, 06:18 PM   #6
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by bftiedt View Post
I was actually typing it out ( I think its easier to remember when actually typing) it just put library right into the line of code so it confused me quite a bit.
This is one reason for always identifying exactly what you're looking at, and exactly what you're working from, whether that's a book, an online tutorial, or a PDF.

If someone with experience can actually look at the exact same file, web page, or book page as you're seeing, then we can probably give a relevant comment. If we don't know exactly what you're seeing, then all we can do is guess.

I make this point now, even after you've solved the problem, because you still haven't identified exactly what you're looking at. I'm not aware of any PDFs of K&R's "The C Programming Language", but I could be wrong. Maybe yours is an old one, and a later version has it fixed. Maybe yours has some kind of formatting defect, unique to wherever you got it from. That's all just guessing, because we don't know exactly what you're looking at.
chown33 is offline   0 Reply With Quote
Old Mar 26, 2012, 06:25 PM   #7
gr4nite
macrumors newbie
 
Join Date: Jan 2012
I haven't looked at C in a little while, but I think your code should also read:

Code:
printf ("hello, world\n" ) ;
Since the new line character is "\n".
gr4nite is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Error compiling hello world sample application on xcode dhanu iPhone/iPad Programming 2 Feb 7, 2009 06:21 PM
No Hello, World! : ( larswik Mac Programming 32 Sep 12, 2006 06:59 PM
Can't compile Hello world app in Xcode (First foray into mac coding) NightLord Mac Programming 6 May 21, 2006 02:32 AM
Hello World problems in C loopfick Mac Programming 10 Mar 22, 2005 04:56 PM
Hello, World. iamchris Community 47 Jul 10, 2002 11:00 PM


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

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC