Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bftiedt

macrumors member
Original poster
Feb 12, 2008
36
0
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 a moderator:

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
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>
[COLOR="Red"]library[/COLOR]
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.
 

bftiedt

macrumors member
Original poster
Feb 12, 2008
36
0
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

macrumors member
Original poster
Feb 12, 2008
36
0
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.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
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.
 

gr4nite

macrumors newbie
Jan 3, 2012
7
0
I haven't looked at C in a little while, but I think your code should also read:

Code:
printf ("hello, world[COLOR="Red"]\[/COLOR]n" ) ;

Since the new line character is "\n".
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.