PDA

View Full Version : Error Running Hello World




bftiedt
Mar 26, 2012, 12:31 PM
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..

#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



chown33
Mar 26, 2012, 12:37 PM
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..

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

bftiedt
Mar 26, 2012, 02:27 PM
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!

robvas
Mar 26, 2012, 03:02 PM
Be careful cutting+pasting from PDF's it doesn't work often.

bftiedt
Mar 26, 2012, 05:00 PM
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
Mar 26, 2012, 06:18 PM
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
Mar 26, 2012, 06:25 PM
I haven't looked at C in a little while, but I think your code should also read:

printf ("hello, world\n" ) ;

Since the new line character is "\n".