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

Similar Threads
thread Thread Starter Forum Replies Last Post
10010 error on 2009 Macbook running Mavericks advice4robots MacBook 0 Dec 27, 2013 01:18 PM
Boot error: iMac running Mavericks GM2 e4xit iMac 7 Nov 17, 2013 08:34 AM
Running iOS 7 GM with iTunes 11.1 error - But am I ok? jererermy iOS 7 19 Sep 15, 2013 06:40 PM
How i can fix "Wiki setting error" and "Running time error" ? Amethyst Mac OS X Server, Xserve, and Networking 0 Sep 2, 2012 01:34 PM
error 2000 when running latest redsnow to jb 4s running 5.1.1 papelboyl1 Jailbreaks and iOS Hacks 4 Jun 9, 2012 03:33 PM

Forum Jump

All times are GMT -5. The time now is 01:11 PM.

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

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